annotate lib-src/etags.c @ 1619:b0f57d54cba5

[xemacs-hg @ 2003-08-12 21:52:28 by youngs] Update xemacs_extra_name.
author youngs
date Tue, 12 Aug 2003 21:52:28 +0000
parents 47ca978d6c75
children 4968c73cb252
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 */
715
add5a821a048 [xemacs-hg @ 2001-12-24 07:44:55 by yoshiki]
yoshiki
parents: 709
diff changeset
55 # ifndef __P
add5a821a048 [xemacs-hg @ 2001-12-24 07:44:55 by yoshiki]
yoshiki
parents: 709
diff changeset
56 # define __P(args) args
add5a821a048 [xemacs-hg @ 2001-12-24 07:44:55 by yoshiki]
yoshiki
parents: 709
diff changeset
57 # endif
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
58 # ifndef PTR
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
59 # define PTR void *
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
60 # endif
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
61 #else
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
62 # if defined(__STDC__) && (__STDC__ || defined(__SUNPRO_C))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
63 # define __P(args) args /* use prototypes */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
64 # define PTR void * /* for generic pointers */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
65 # else
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
66 # define __P(args) () /* no prototypes */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
67 # define const /* remove const for old compilers' sake */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
68 # define PTR long * /* don't use void* */
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
69 # endif
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
70 #endif /* !HAVE_CONFIG_H */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 428
diff changeset
72 #ifndef _GNU_SOURCE
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 428
diff changeset
73 # define _GNU_SOURCE 1 /* enables some compiler checks on GNU */
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 428
diff changeset
74 #endif
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 428
diff changeset
75
920
47ca978d6c75 [xemacs-hg @ 2002-07-14 14:23:43 by adrian]
adrian
parents: 771
diff changeset
76 /* WIN32_NATIVE is for XEmacs.
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
77 MSDOS, WINDOWSNT, DOS_NT are for Emacs. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
78 #ifdef WIN32_NATIVE
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
79 # undef MSDOS
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
80 # undef WINDOWSNT
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
81 # define WINDOWSNT
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
82 #endif /* WIN32_NATIVE */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
83
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
84 #ifdef MSDOS
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
85 # undef MSDOS
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
86 # define MSDOS TRUE
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
87 # include <fcntl.h>
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
88 # include <sys/param.h>
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
89 # include <io.h>
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
90 # ifndef HAVE_CONFIG_H
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
91 # define DOS_NT
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
92 # include <sys/config.h>
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
93 # endif
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
94 #else
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
95 # define MSDOS FALSE
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
96 #endif /* MSDOS */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
97
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
98 #ifdef WINDOWSNT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 # include <stdlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 # include <fcntl.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 # include <string.h>
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
102 # include <direct.h>
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 # include <io.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 # define MAXPATHLEN _MAX_PATH
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
105 # undef HAVE_NTGUI
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
106 # undef DOS_NT
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
107 # define DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 # ifndef HAVE_GETCWD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 # define HAVE_GETCWD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 # endif /* undef HAVE_GETCWD */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
111 #else /* !WINDOWSNT */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
112 # ifdef STDC_HEADERS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
113 # include <stdlib.h>
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
114 # include <string.h>
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
115 # else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
116 extern char *getenv ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
117 # endif
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
118 #endif /* !WINDOWSNT */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 #ifdef HAVE_UNISTD_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 # include <unistd.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 #else
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
123 # if defined (HAVE_GETCWD) && !defined (WINDOWSNT)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
124 extern char *getcwd (char *buf, size_t size);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 # endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 #endif /* HAVE_UNISTD_H */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 #include <ctype.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 #include <errno.h>
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
131 #ifndef errno
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
132 extern int errno;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
133 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 #include <sys/types.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 #include <sys/stat.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
137 #include <assert.h>
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
138 #ifdef NDEBUG
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
139 # undef assert /* some systems have a buggy assert.h */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
140 # define assert(x) ((void) 0)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
141 #endif
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
142
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 #if !defined (S_ISREG) && defined (S_IFREG)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 #ifdef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 # include <getopt.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 # define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 extern char *optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 extern int optind, opterr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 #endif /* LONG_OPTIONS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 #ifdef ETAGS_REGEXPS
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
156 # 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
157 # ifdef __CYGWIN__ /* compiling on Cygwin */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
158 !!! NOTICE !!!
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
159 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
160 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
161 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
162 # endif
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
163 # endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 # include <regex.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 /* Define CTAGS to make the program "ctags" compatible with the usual one.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 Leave it undefined to make the program "etags", which makes emacs-style
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 tag tables and tags typedefs, #defines and struct/union/enum by default. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 #ifdef CTAGS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 # undef CTAGS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 # define CTAGS TRUE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 # define CTAGS FALSE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 /* Exit codes for success and failure. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 #ifdef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 # define GOOD 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 # define BAD 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 # define GOOD 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 # define BAD 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
186 #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
187 #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
188
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 #define CHARS 256 /* 2^sizeof(char) */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
190 #define CHAR(x) ((unsigned int)(x) & (CHARS - 1))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 #define iswhite(c) (_wht[CHAR(c)]) /* c is white */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 #define notinname(c) (_nin[CHAR(c)]) /* c is not in a name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 #define begtoken(c) (_btk[CHAR(c)]) /* c can start token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 #define intoken(c) (_itk[CHAR(c)]) /* c can be in token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 #define endtoken(c) (_etk[CHAR(c)]) /* c ends tokens */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
197 #define ISALNUM(c) isalnum (CHAR(c))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
198 #define ISALPHA(c) isalpha (CHAR(c))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
199 #define ISDIGIT(c) isdigit (CHAR(c))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
200 #define ISLOWER(c) islower (CHAR(c))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
201
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
202 #define lowcase(c) tolower (CHAR(c))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
203 #define upcase(c) toupper (CHAR(c))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
204
428
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 * xnew, xrnew -- allocate, reallocate storage
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 * SYNOPSIS: Type *xnew (int n, Type);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
210 * void xrnew (OldPointer, int n, Type);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
212 #if DEBUG
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 # include "chkmalloc.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 # define xnew(n,Type) ((Type *) trace_malloc (__FILE__, __LINE__, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 (n) * sizeof (Type)))
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
216 # define xrnew(op,n,Type) ((op) = (Type *) trace_realloc (__FILE__, __LINE__, \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
217 (char *) (op), (n) * sizeof (Type)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 # define xnew(n,Type) ((Type *) xmalloc ((n) * sizeof (Type)))
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
220 # define xrnew(op,n,Type) ((op) = (Type *) xrealloc ( \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
221 (char *) (op), (n) * sizeof (Type)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
224 #define bool int
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
225
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
226 typedef void Lang_function __P((FILE *));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 char *suffix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 char *command; /* Takes one arg and decompresses to stdout */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 } compressor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 Lang_function *function;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
238 char **filenames;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 char **suffixes;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 char **interpreters;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 } language;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 typedef struct node_st
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 { /* sorting structure */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 char *name; /* function or type name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 char *file; /* file name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 bool is_func; /* use pattern or line no */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 bool been_warned; /* set if noticed dup */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 int lno; /* line number tag is on */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 long cno; /* character number line starts on */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 char *pat; /* search pattern */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 struct node_st *left, *right; /* left and right sons */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 } node;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 * A `linebuffer' is a structure which holds a line of text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 * `readline_internal' reads a line from a stream into a linebuffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 * and works regardless of the length of the line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 * 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
260 * BUFFER after readline reads it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 long size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 char *buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 } linebuffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 /* Many compilers barf on this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 Lang_function Ada_funcs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 so let's write it this way */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
272 static void Ada_funcs __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
273 static void Asm_labels __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
274 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
275 static void default_C_entries __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
276 static void plain_C_entries __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
277 static void Cjava_entries __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
278 static void Cobol_paragraphs __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
279 static void Cplusplus_entries __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
280 static void Cstar_entries __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
281 static void Erlang_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
282 static void Fortran_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
283 static void Yacc_entries __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
284 static void Lisp_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
285 static void Makefile_targets __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
286 static void Pascal_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
287 static void Perl_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
288 static void PHP_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
289 static void Postscript_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
290 static void Prolog_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
291 static void Python_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
292 static void Scheme_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
293 static void TeX_commands __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
294 static void Texinfo_nodes __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
295 static void just_read_file __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
296
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
297 static void print_language_names __P((void));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
298 static void print_version __P((void));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
299 static void print_help __P((void));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
300 int main __P((int, char **));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
301 static int number_len __P((long));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
302
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
303 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
304 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
305 static language *get_language_from_interpreter __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
306 static language *get_language_from_filename __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
307 static int total_size_of_entries __P((node *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
308 static long readline __P((linebuffer *, FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
309 static long readline_internal __P((linebuffer *, FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
310 static void get_tag __P((char *));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 #ifdef ETAGS_REGEXPS
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
313 static void analyse_regex __P((char *, bool));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
314 static void add_regex __P((char *, bool, language *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
315 static void free_patterns __P((void));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 #endif /* ETAGS_REGEXPS */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
317 static void error __P((const char *, const char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
318 static void suggest_asking_for_help __P((void));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
319 void fatal __P((char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
320 static void pfatal __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
321 static void add_node __P((node *, node **));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
322
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
323 static void init __P((void));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
324 static void initbuffer __P((linebuffer *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
325 static void find_entries __P((char *, FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
326 static void free_tree __P((node *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
327 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
328 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
329 static void process_file __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
330 static void put_entries __P((node *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
331 static void takeprec __P((void));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
332
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
333 static char *concat __P((char *, char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
334 static char *skip_spaces __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
335 static char *skip_non_spaces __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
336 static char *savenstr __P((char *, int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
337 static char *savestr __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
338 static char *etags_strchr __P((const char *, int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
339 static char *etags_strrchr __P((const char *, int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
340 static char *etags_getcwd __P((void));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
341 static char *relative_filename __P((char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
342 static char *absolute_filename __P((char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
343 static char *absolute_dirname __P((char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
344 static bool filename_is_absolute __P((char *f));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
345 static void canonicalize_filename __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
346 static void linebuffer_setlen __P((linebuffer *, int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
347 PTR xmalloc __P((unsigned int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
348 PTR xrealloc __P((char *, unsigned int));
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 char searchar = '/'; /* use /.../ searches */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 char *tagfile; /* output file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 char *progname; /* name this program was invoked with */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 char *cwd; /* current working directory */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 char *tagfiledir; /* directory of tagfile */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 FILE *tagf; /* ioptr for tags file */
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 char *curfile; /* current input file name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 language *curlang; /* current language */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 int lineno; /* line number of current line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 long charno; /* current character number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 long linecharno; /* charno of start of current line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 char *dbp; /* pointer to start of current tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 node *head; /* the head of the binary tree of tags */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 linebuffer lb; /* the current line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 /* boolean "functions" (see init) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 bool _wht[CHARS], _nin[CHARS], _itk[CHARS], _btk[CHARS], _etk[CHARS];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 char
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 /* white chars */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
375 *white = " \f\t\n\r\v",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 /* not in a name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 *nonam = " \f\t\n\r(=,[;",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 /* token ending chars */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 *endtk = " \t\n\r\"'#()[]{}=-+%*/&|^~!<>;,.:?",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 /* token starting chars */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 *begtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~@",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 /* valid in-token chars */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 *midtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 bool append_to_tagfile; /* -a: append to tags */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 /* 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
387 bool typedefs; /* -t: create tags for C and Ada typedefs */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
388 bool typedefs_or_cplusplus; /* -T: create tags for C typedefs, level */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 /* 0 struct/enum/union decls, and C++ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 /* member functions. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 bool constantypedefs; /* -d: create tags for C #define, enum */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 /* constants and variables. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 /* -D: opposite of -d. Default under ctags. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 bool declarations; /* --declarations: tag them and extern in C&Co*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 bool globals; /* create tags for global variables */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 bool members; /* create tags for C member variables */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 bool update; /* -u: update tags */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 bool vgrind_style; /* -v: create vgrind style index output */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 bool no_warnings; /* -w: suppress warnings */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 bool cxref_style; /* -x: create cxref style output */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 bool cplusplus; /* .[hc] means C++, not C */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 bool noindentypedefs; /* -I: ignore indentation in C */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 bool packages_only; /* --packages-only: in Ada, only tag packages*/
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 #ifdef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 struct option longopts[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 { "packages-only", no_argument, &packages_only, TRUE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 { "append", no_argument, NULL, 'a' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 { "backward-search", no_argument, NULL, 'B' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 { "c++", no_argument, NULL, 'C' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 { "cxref", no_argument, NULL, 'x' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 { "defines", no_argument, NULL, 'd' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 { "declarations", no_argument, &declarations, TRUE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 { "no-defines", no_argument, NULL, 'D' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 { "globals", no_argument, &globals, TRUE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 { "no-globals", no_argument, &globals, FALSE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 { "help", no_argument, NULL, 'h' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 { "help", no_argument, NULL, 'H' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 { "ignore-indentation", no_argument, NULL, 'I' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 { "include", required_argument, NULL, 'i' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 { "language", required_argument, NULL, 'l' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 { "members", no_argument, &members, TRUE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 { "no-members", no_argument, &members, FALSE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 { "no-warn", no_argument, NULL, 'w' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 { "output", required_argument, NULL, 'o' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 { "regex", required_argument, NULL, 'r' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 { "no-regex", no_argument, NULL, 'R' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 { "ignore-case-regex", required_argument, NULL, 'c' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 { "typedefs", no_argument, NULL, 't' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 { "typedefs-and-c++", no_argument, NULL, 'T' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 { "update", no_argument, NULL, 'u' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 { "version", no_argument, NULL, 'V' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 { "vgrind", no_argument, NULL, 'v' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 { NULL }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 #endif /* LONG_OPTIONS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 /* Structure defining a regular expression. Elements are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 the compiled pattern, and the name string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 typedef struct pattern
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 struct pattern *p_next;
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
447 language *lang;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 char *regex;
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
449 struct re_pattern_buffer *pat;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 struct re_registers regs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 char *name_pattern;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 bool error_signaled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 } pattern;
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 /* List of all regexps. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 pattern *p_head = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 /* How many characters in the character set. (From regex.c.) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 #define CHAR_SET_SIZE 256
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 /* Translation table for case-insensitive matching. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 char lc_trans[CHAR_SET_SIZE];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 compressor compressors[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 { "z", "gzip -d -c"},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 { "Z", "gzip -d -c"},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 { "gz", "gzip -d -c"},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 { "GZ", "gzip -d -c"},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 { "bz2", "bzip2 -d -c" },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 { NULL }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473
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 * Language stuff.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 /* Non-NULL if language fixed. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 language *forced_lang = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 /* Ada code */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 char *Ada_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 { "ads", "adb", "ada", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 /* Assembly code */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 char *Asm_suffixes [] = { "a", /* Unix assembler */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 "asm", /* Microcontroller assembly */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 "def", /* BSO/Tasking definition includes */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 "inc", /* Microcontroller include files */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 "ins", /* Microcontroller include files */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 "s", "sa", /* Unix assembler */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 "S", /* cpp-processed Unix assembler */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 "src", /* BSO/Tasking C compiler output */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 NULL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 /* 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
498 given, or if the `class' keyowrd is met inside the file.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
499 That is why default_C_entries is called for these. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 char *default_C_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 { "c", "h", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 char *Cplusplus_suffixes [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
504 { "C", "c++", "cc", "cpp", "cxx", "H", "h++", "hh", "hpp", "hxx",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 "M", /* Objective C++ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 "pdb", /* Postscript with C syntax */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 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 *Cjava_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 { "java", 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 *Cobol_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 { "COB", "cob", 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 *Cstar_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 { "cs", "hs", 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 *Erlang_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 { "erl", "hrl", 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 *Fortran_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 { "F", "f", "f90", "for", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 char *Lisp_suffixes [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
525 { "cl", "clisp", "el", "l", "lisp", "LSP", "lsp", "ml", NULL };
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
526
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
527 char *Makefile_filenames [] =
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
528 { "Makefile", "makefile", "GNUMakefile", "Makefile.in", "Makefile.am", NULL};
428
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 *Pascal_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 { "p", "pas", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 char *Perl_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 { "pl", "pm", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 char *Perl_interpreters [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 { "perl", "@PERL@", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
538 char *PHP_suffixes [] =
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
539 { "php", "php3", "php4", NULL };
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
540
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 char *plain_C_suffixes [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
542 { "lm", /* Objective lex file */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 "m", /* Objective C file */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
544 "pc", /* Pro*C file */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 NULL };
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 *Postscript_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 { "ps", "psw", NULL }; /* .psw is for PSWrap */
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 *Prolog_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 { "prolog", 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 char *Python_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 { "py", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 /* Can't do the `SCM' or `scm' prefix with a version number. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 char *Scheme_suffixes [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
558 { "oak", "sch", "scheme", "SCM", "scm", "SM", "sm", "ss", "t", NULL };
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 char *TeX_suffixes [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
561 { "bib", "clo", "cls", "ltx", "sty", "TeX", "tex", NULL };
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
562
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
563 char *Texinfo_suffixes [] =
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
564 { "texi", "texinfo", "txi", NULL };
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 char *Yacc_suffixes [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
567 { "y", "y++", "ym", "yxx", "yy", NULL }; /* .ym is Objective yacc file */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 * Table of languages.
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 * 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
573 * name. I just didn't.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 language lang_names [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
578 { "ada", Ada_funcs, NULL, Ada_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
579 { "asm", Asm_labels, NULL, Asm_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
580 { "c", default_C_entries, NULL, default_C_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
581 { "c++", Cplusplus_entries, NULL, Cplusplus_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
582 { "c*", Cstar_entries, NULL, Cstar_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
583 { "cobol", Cobol_paragraphs, NULL, Cobol_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
584 { "erlang", Erlang_functions, NULL, Erlang_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
585 { "fortran", Fortran_functions, NULL, Fortran_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
586 { "java", Cjava_entries, NULL, Cjava_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
587 { "lisp", Lisp_functions, NULL, Lisp_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
588 { "makefile", Makefile_targets, Makefile_filenames, NULL, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
589 { "pascal", Pascal_functions, NULL, Pascal_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
590 { "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
591 { "php", PHP_functions, NULL, PHP_suffixes, NULL },
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
592 { "postscript", Postscript_functions, NULL, Postscript_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
593 { "proc", plain_C_entries, NULL, plain_C_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
594 { "prolog", Prolog_functions, NULL, Prolog_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
595 { "python", Python_functions, NULL, Python_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
596 { "scheme", Scheme_functions, NULL, Scheme_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
597 { "tex", TeX_commands, NULL, TeX_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
598 { "texinfo", Texinfo_nodes, NULL, Texinfo_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
599 { "yacc", Yacc_entries, NULL, Yacc_suffixes, NULL },
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 { "auto", NULL }, /* default guessing scheme */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 { "none", just_read_file }, /* regexp matching only */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 { NULL, NULL } /* end of list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 };
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
604
428
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 print_language_names ()
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 language *lang;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
610 char **name, **ext;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 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
613 default file names and dot suffixes:");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
616 printf (" %-*s", 10, lang->name);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
617 if (lang->filenames != NULL)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
618 for (name = lang->filenames; *name != NULL; name++)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
619 printf (" %s", *name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 if (lang->suffixes != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 for (ext = lang->suffixes; *ext != NULL; ext++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 printf (" .%s", *ext);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 puts ("");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 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
626 name suffix, and `none' means only do regexp processing on files.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 If no language is specified and no matching suffix is found,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 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
629 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
630 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
631 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
632 Compressed files are supported using gzip and bzip2.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
635 #ifndef EMACS_NAME
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 # define EMACS_NAME "GNU Emacs"
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 #ifndef VERSION
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
639 # define VERSION "21"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 print_version ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
644 printf ("%s (%s %s)\n", (CTAGS) ? "ctags" : "etags", EMACS_NAME, VERSION);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 puts ("Copyright (C) 1999 Free Software Foundation, Inc. and Ken Arnold");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 puts ("This program is distributed under the same terms as Emacs");
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 exit (GOOD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 }
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 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 print_help ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 printf ("Usage: %s [options] [[regex-option ...] file-name] ...\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 These are the options accepted by %s.\n", progname, progname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 #ifdef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 puts ("You may use unambiguous abbreviations for the long option names.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 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
661 linked with GNU getopt.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 #endif /* LONG_OPTIONS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 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
664 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 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
666 Relative ones are stored relative to the output file's directory.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 puts ("\n");
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 ("-a, --append\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 Append tag entries to existing tags file.");
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 puts ("--packages-only\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 For Ada files, only generate tags for packages .");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 puts ("-B, --backward-search\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 Write the search commands for the tag entries using '?', the\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 backward-search command instead of '/', the forward-search command.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
680 /* This option is mostly obsolete, because etags can now automatically
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
681 detect C++. Retained for backward compatibility and for debugging and
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
682 experimentation. In principle, we could want to tag as C++ even
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
683 before any "class" keyword.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 puts ("-C, --c++\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 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
686 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 puts ("--declarations\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 In C and derived languages, create tags for function declarations,");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 puts ("\tand create tags for extern variables if --globals is used.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 puts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 ("\tand create tags for extern variables unless --no-globals is used.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 puts ("-d, --defines\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 Create tag entries for C #define constants and enum constants, too.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 puts ("-D, --no-defines\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 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
702 This makes the tags file smaller.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 puts ("-i FILE, --include=FILE\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 Include a note in tag file indicating that, when searching for\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 a tag, one should also consult the tags file FILE after\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 checking the current file.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 puts ("-l LANG, --language=LANG\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 Force the following files to be considered as written in the\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 named language up to the next --language=LANG option.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 puts ("--globals\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 Create tag entries for global variables in some languages.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 puts ("--no-globals\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 Do not create tag entries for global variables in some\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 languages. This makes the tags file smaller.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 puts ("--members\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 Create tag entries for member variables in C and derived languages.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 puts ("-r /REGEXP/, --regex=/REGEXP/ or --regex=@regexfile\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 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
728 files. {LANGUAGE}/REGEXP/ uses REGEXP for LANGUAGE files only.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 regexfile is a file containing one REGEXP per line.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 REGEXP is anchored (as if preceded by ^).\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 The form /REGEXP/NAME/ creates a named tag.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 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
733 --regex=\"/proc[ \\t]+\\([^ \\t]+\\)/\\1/.\"");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 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
735 Like -r, --regex but ignore case when matching expressions.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 puts ("-R, --no-regex\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 Don't create tags from regexps for the following files.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 puts ("-o FILE, --output=FILE\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 Write the tags to FILE.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 puts ("-I, --ignore-indentation\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 Don't rely on indentation quite as much as normal. Currently,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 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
744 column is the final brace of a function or structure\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 definition in C and C++.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 puts ("-t, --typedefs\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 Generate tag entries for C and Ada typedefs.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 puts ("-T, --typedefs-and-c++\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 Generate tag entries for C typedefs, C struct/enum/union tags,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 and C++ member functions.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 puts ("-u, --update\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 Update the tag entries for the given files, leaving tag\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 entries for other files in place. Currently, this is\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 implemented by deleting the existing entries for the given\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 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
759 tags file. It is often faster to simply rebuild the entire\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 tag file than to use this.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 puts ("-v, --vgrind\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 Generates an index of items intended for human consumption,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 similar to the output of vgrind. The index is sorted, and\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 gives the page number of each item.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 puts ("-w, --no-warn\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 Suppress warning messages about entries defined in multiple\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 files.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 puts ("-x, --cxref\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 Like --vgrind, but in the style of cxref, rather than vgrind.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 The output uses line numbers instead of page numbers, but\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 beyond that the differences are cosmetic; try both to see\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 which you like.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 puts ("-V, --version\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 Print the version of the program.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 -h, --help\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 Print this help message.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 print_language_names ();
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 puts ("");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 puts ("Report bugs to bug-gnu-emacs@gnu.org");
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 exit (GOOD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 }
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 enum argument_type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 at_language,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 at_regexp,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 at_filename,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 at_icregexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 };
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 /* This structure helps us allow mixing of --lang and file names. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 enum argument_type arg_type;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 char *what;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 language *lang; /* language of the regexp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 } argument;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 #ifdef VMS /* VMS specific functions */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 #define EOS '\0'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 /* This is a BUG! ANY arbitrary limit is a BUG!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 Won't someone please fix this? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 #define MAX_FILE_SPEC_LEN 255
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 typedef struct {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 short curlen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 char body[MAX_FILE_SPEC_LEN + 1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 } vspec;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 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
819 returning in each successive call the next file name matching the input
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 spec. The function expects that each in_spec passed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 to it will be processed to completion; in particular, up to and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 including the call following that in which the last matching name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 is returned, the function ignores the value of in_spec, and will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 only start processing a new spec with the following call.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 If an error occurs, on return out_spec contains the value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 of in_spec when the error occurred.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 With each successive file name returned in out_spec, the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 function's return value is one. When there are no more matching
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 names the function returns zero. If on the first call no file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 matches in_spec, or there is any other error, -1 is returned.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 #include <rmsdef.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 #include <descrip.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 #define OUTSIZE MAX_FILE_SPEC_LEN
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
837 static short
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 fn_exp (out, in)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 vspec *out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 char *in;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 static long context = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 static struct dsc$descriptor_s o;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 static struct dsc$descriptor_s i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 static bool pass1 = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 long status;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 short retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 if (pass1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 pass1 = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 o.dsc$a_pointer = (char *) out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 o.dsc$w_length = (short)OUTSIZE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 i.dsc$a_pointer = in;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 i.dsc$w_length = (short)strlen(in);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 i.dsc$b_dtype = DSC$K_DTYPE_T;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 i.dsc$b_class = DSC$K_CLASS_S;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 o.dsc$b_dtype = DSC$K_DTYPE_VT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 o.dsc$b_class = DSC$K_CLASS_VS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 if ((status = lib$find_file(&i, &o, &context, 0, 0)) == RMS$_NORMAL)
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 out->body[out->curlen] = EOS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 else if (status == RMS$_NMF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 retval = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 else
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 strcpy(out->body, in);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 retval = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 lib$find_file_end(&context);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 pass1 = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 return retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 v1.01 nmm 19-Aug-85 gfnames - return in successive calls the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 name of each file specified by the provided arg expanding wildcards.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
882 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 gfnames (arg, p_error)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 char *arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 bool *p_error;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 static vspec filename = {MAX_FILE_SPEC_LEN, "\0"};
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 switch (fn_exp (&filename, arg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 case 1:
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 filename.body;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 case 0:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 *p_error = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 *p_error = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 return filename.body;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 #ifndef OLD /* Newer versions of VMS do provide `system'. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 system (cmd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 char *cmd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 error ("%s", "system() function not implemented under VMS");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 #define VERSION_DELIM ';'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 char *massage_name (s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 char *start = s;
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 for ( ; *s; s++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 if (*s == VERSION_DELIM)
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 *s = EOS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 *s = lowcase (*s);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 return start;
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 #endif /* VMS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 main (argc, argv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 int argc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 char *argv[];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 unsigned int nincluded_files;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 char **included_files;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 char *this_file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 argument *argbuffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 int current_arg, file_count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 linebuffer filename_lb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 #ifdef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 bool got_err;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
946 #ifdef DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 _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
948 #endif /* DOS_NT */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 progname = argv[0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 nincluded_files = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 included_files = xnew (argc, char *);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 current_arg = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 file_count = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 /* Allocate enough no matter what happens. Overkill, but each one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 is small. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 argbuffer = xnew (argc, argument);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 /* Set syntax for regular expression routines. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 re_set_syntax (RE_SYNTAX_EMACS | RE_INTERVALS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 /* Translation table for case-insensitive search. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 for (i = 0; i < CHAR_SET_SIZE; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 lc_trans[i] = lowcase (i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 * If etags, always find typedefs and structure tags. Why not?
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
970 * Also default to find macro constants, enum constants and
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 * global variables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
975 typedefs = typedefs_or_cplusplus = constantypedefs = TRUE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 globals = TRUE;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
977 declarations = FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 members = FALSE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 while (1)
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 int opt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 char *optstring;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 optstring = "-aCdDf:Il:o:r:c:RStTi:BuvxwVhH";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 optstring = "-aCdDf:Il:o:StTi:BuvxwVhH";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 #ifndef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 optstring = optstring + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 #endif /* LONG_OPTIONS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 opt = getopt_long (argc, argv, optstring, longopts, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 if (opt == EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 switch (opt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 case 0:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 /* If getopt returns 0, then it has already processed a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 long-named option. We should do nothing. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 case 1:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 /* This means that a file name has been seen. Record it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 argbuffer[current_arg].arg_type = at_filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 argbuffer[current_arg].what = optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 ++file_count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 /* Common options. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 case 'a': append_to_tagfile = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 case 'C': cplusplus = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 case 'd': constantypedefs = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 case 'D': constantypedefs = FALSE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 case 'f': /* for compatibility with old makefiles */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 case 'o':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 if (tagfile)
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 error ("-o option may only be given once.", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 suggest_asking_for_help ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 tagfile = optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 case 'I':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 case 'S': /* for backward compatibility */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 noindentypedefs = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 case 'l':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1035 language *lang = get_language_from_langname (optarg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 if (lang != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 argbuffer[current_arg].lang = lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 argbuffer[current_arg].arg_type = at_language;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 case 'r':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 argbuffer[current_arg].arg_type = at_regexp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 argbuffer[current_arg].what = optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 case 'R':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 argbuffer[current_arg].arg_type = at_regexp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 argbuffer[current_arg].what = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 case 'c':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 argbuffer[current_arg].arg_type = at_icregexp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 argbuffer[current_arg].what = optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 case 'V':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 print_version ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 case 'h':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 case 'H':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 print_help ();
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':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 typedefs = TRUE;
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 case 'T':
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1072 typedefs = typedefs_or_cplusplus = TRUE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 #if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 /* Etags options */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 case 'i':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 included_files[nincluded_files++] = optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 #else /* CTAGS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 /* Ctags options. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 case 'B': searchar = '?'; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 case 'u': update = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 case 'v': vgrind_style = TRUE; /*FALLTHRU*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 case 'x': cxref_style = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 case 'w': no_warnings = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 #endif /* CTAGS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 suggest_asking_for_help ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 for (; optind < argc; ++optind)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 argbuffer[current_arg].arg_type = at_filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 argbuffer[current_arg].what = argv[optind];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 ++file_count;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 if (nincluded_files == 0 && file_count == 0)
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 error ("no input files specified.", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 suggest_asking_for_help ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 if (tagfile == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 tagfile = CTAGS ? "tags" : "TAGS";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 cwd = etags_getcwd (); /* the current working directory */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 if (cwd[strlen (cwd) - 1] != '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 char *oldcwd = cwd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 cwd = concat (oldcwd, "/", "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 free (oldcwd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 if (streq (tagfile, "-"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 tagfiledir = cwd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 tagfiledir = absolute_dirname (tagfile, cwd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 init (); /* set up boolean "functions" */
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 initbuffer (&lb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 initbuffer (&filename_lb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 if (streq (tagfile, "-"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 tagf = stdout;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1130 #ifdef DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 /* Switch redirected `stdout' to binary mode (setting `_fmode'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 doesn't take effect until after `stdout' is already open). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 if (!isatty (fileno (stdout)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 setmode (fileno (stdout), O_BINARY);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1135 #endif /* DOS_NT */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 if (tagf == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 pfatal (tagfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 * Loop through files finding functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 for (i = 0; i < current_arg; ++i)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 switch (argbuffer[i].arg_type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 case at_language:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 forced_lang = argbuffer[i].lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 case at_regexp:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 analyse_regex (argbuffer[i].what, FALSE);
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 case at_icregexp:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 analyse_regex (argbuffer[i].what, TRUE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 case at_filename:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 #ifdef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163 while ((this_file = gfnames (argbuffer[i].what, &got_err)) != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 if (got_err)
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 error ("can't find file %s\n", this_file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 argc--, argv++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172 this_file = massage_name (this_file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175 this_file = argbuffer[i].what;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 /* Input file named "-" means read file names from stdin
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178 (one per line) and use them. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 if (streq (this_file, "-"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 while (readline_internal (&filename_lb, stdin) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 process_file (filename_lb.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 process_file (this_file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 #ifdef VMS
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 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 free_patterns ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 if (!CTAGS)
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 while (nincluded_files-- > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198 fprintf (tagf, "\f\n%s,include\n", *included_files++);
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 fclose (tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201 exit (GOOD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 /* 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
1205 because we want them ordered. Let's do it now. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 if (cxref_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 put_entries (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 free_tree (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 head = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 exit (GOOD);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 if (update)
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 char cmd[BUFSIZ];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 for (i = 0; i < current_arg; ++i)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 if (argbuffer[i].arg_type != at_filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 sprintf (cmd,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223 tagfile, argbuffer[i].what, tagfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 if (system (cmd) != GOOD)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 fatal ("failed to execute shell command", (char *)NULL);
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 append_to_tagfile = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 if (tagf == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 pfatal (tagfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 put_entries (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234 free_tree (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 head = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 fclose (tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 if (update)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 char cmd[BUFSIZ];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 sprintf (cmd, "sort %s -o %s", tagfile, tagfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242 exit (system (cmd));
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 return GOOD;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1248
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250 * Return a compressor given the file name. If EXTPTR is non-zero,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251 * return a pointer into FILE where the compressor-specific
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252 * extension begins. If no compressor is found, NULL is returned
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253 * and EXTPTR is not significant.
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1254 * Idea by Vladimir Alexiev <vladimir@cs.ualberta.ca> (1998)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1256 static compressor *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257 get_compressor_from_suffix (file, extptr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 char *file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 char **extptr;
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 compressor *compr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262 char *slash, *suffix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 /* This relies on FN to be after canonicalize_filename,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1265 so we don't need to consider backslashes on DOS_NT. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266 slash = etags_strrchr (file, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267 suffix = etags_strrchr (file, '.');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268 if (suffix == NULL || suffix < slash)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 if (extptr != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271 *extptr = suffix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272 suffix += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 /* 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
1274 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
1275 Only the first do loop is run if not MSDOS */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278 for (compr = compressors; compr->suffix != NULL; compr++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 if (streq (compr->suffix, suffix))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 return compr;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1281 if (!MSDOS)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1282 break; /* do it only once: not really a loop */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 if (extptr != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 *extptr = ++suffix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285 } while (*suffix != '\0');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286 return NULL;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1290
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 * Return a language given the name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1294 static language *
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1295 get_language_from_langname (name)
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
1296 const char *name;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1300 if (name == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301 error ("empty language name", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1305 if (streq (name, lang->name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306 return lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307 error ("unknown language \"%s\"", name);
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 return NULL;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1314 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1315 * Return a language given the interpreter name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1317 static language *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318 get_language_from_interpreter (interpreter)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1319 char *interpreter;
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 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1322 char **iname;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1323
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1324 if (interpreter == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1325 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1326 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1327 if (lang->interpreters != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1328 for (iname = lang->interpreters; *iname != NULL; iname++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1329 if (streq (*iname, interpreter))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1330 return lang;
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 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1333 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1334
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1335
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1336
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1337 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1338 * Return a language given the file name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1339 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1340 static language *
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1341 get_language_from_filename (file)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342 char *file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1343 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1344 language *lang;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1345 char **name, **ext, *suffix;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1346
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1347 /* Try whole file name first. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1348 for (lang = lang_names; lang->name != NULL; lang++)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1349 if (lang->filenames != NULL)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1350 for (name = lang->filenames; *name != NULL; name++)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1351 if (streq (*name, file))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1352 return lang;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1353
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1354 /* If not found, try suffix after last dot. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 suffix = etags_strrchr (file, '.');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 if (suffix == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358 suffix += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360 if (lang->suffixes != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 for (ext = lang->suffixes; *ext != NULL; ext++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1362 if (streq (*ext, suffix))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 return lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 return NULL;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370 * This routine is called on each file argument.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1372 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 process_file (file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 char *file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376 struct stat stat_buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378 compressor *compr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 char *compressed_name, *uncompressed_name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380 char *ext, *real_name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381
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 canonicalize_filename (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 if (streq (file, tagfile) && !streq (tagfile, "-"))
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 error ("skipping inclusion of %s in self.", file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389 if ((compr = get_compressor_from_suffix (file, &ext)) == NULL)
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 compressed_name = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392 real_name = uncompressed_name = savestr (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 else
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 real_name = compressed_name = savestr (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397 uncompressed_name = savenstr (file, ext - file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398 }
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 /* If the canonicalised uncompressed name has already be dealt with,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401 skip it silently, else add it to the list. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403 typedef struct processed_file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405 char *filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406 struct processed_file *next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407 } processed_file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 static processed_file *pf_head = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409 register processed_file *fnp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 for (fnp = pf_head; fnp != NULL; fnp = fnp->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412 if (streq (uncompressed_name, fnp->filename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 goto exit;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414 fnp = pf_head;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 pf_head = xnew (1, struct processed_file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416 pf_head->filename = savestr (uncompressed_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417 pf_head->next = fnp;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1420 if (stat (real_name, &stat_buf) != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 /* Reset real_name and try with a different name. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423 real_name = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 if (compressed_name != NULL) /* try with the given suffix */
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 if (stat (uncompressed_name, &stat_buf) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427 real_name = uncompressed_name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1428 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1429 else /* try all possible suffixes */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1430 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431 for (compr = compressors; compr->suffix != NULL; compr++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1433 compressed_name = concat (file, ".", compr->suffix);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434 if (stat (compressed_name, &stat_buf) != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1435 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1436 if (MSDOS)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1437 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1438 char *suf = compressed_name + strlen (file);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1439 size_t suflen = strlen (compr->suffix) + 1;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1440 for ( ; suf[1]; suf++, suflen--)
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 memmove (suf, suf + 1, suflen);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1443 if (stat (compressed_name, &stat_buf) == 0)
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 real_name = compressed_name;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1446 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1447 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1448 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1449 if (real_name != NULL)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1450 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1451 } /* MSDOS */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 free (compressed_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453 compressed_name = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1454 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 else
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 real_name = compressed_name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1458 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1459 }
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1462 if (real_name == NULL)
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 perror (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1465 goto exit;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1466 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467 } /* try with a different name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1468
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 if (!S_ISREG (stat_buf.st_mode))
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 error ("skipping %s: it is not a regular file.", real_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472 goto exit;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1474 if (real_name == compressed_name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476 char *cmd = concat (compr->command, " ", real_name);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1477 inf = (FILE *) popen (cmd, "r");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478 free (cmd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1479 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1481 inf = fopen (real_name, "r");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482 if (inf == NULL)
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 perror (real_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1485 goto exit;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488 find_entries (uncompressed_name, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 if (real_name == compressed_name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491 pclose (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493 fclose (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497 char *filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 if (filename_is_absolute (uncompressed_name))
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 /* file is an absolute file name. Canonicalise it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 filename = absolute_filename (uncompressed_name, cwd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1506 /* file is a file name relative to cwd. Make it relative
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507 to the directory of the tags file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 filename = relative_filename (uncompressed_name, tagfiledir);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510 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
1511 free (filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512 put_entries (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1513 free_tree (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514 head = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1516
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1517 exit:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518 if (compressed_name) free(compressed_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1519 if (uncompressed_name) free(uncompressed_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1520 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1521 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1522
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1523 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524 * This routine sets up the boolean pseudo-functions which work
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525 * by setting boolean flags dependent upon the corresponding character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526 * 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
1527 * 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
1528 * subscripted by the chars in "white" are set to TRUE. Thus "_wht"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1529 * 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
1530 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1531 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532 init ()
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 register char *sp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535 register int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1536
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1537 for (i = 0; i < CHARS; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1538 iswhite(i) = notinname(i) = begtoken(i) = intoken(i) = endtoken(i) = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539 for (sp = white; *sp != '\0'; sp++) iswhite (*sp) = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540 for (sp = nonam; *sp != '\0'; sp++) notinname (*sp) = TRUE;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1541 notinname('\0') = notinname('\n');
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1542 for (sp = begtk; *sp != '\0'; sp++) begtoken (*sp) = TRUE;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1543 begtoken('\0') = begtoken('\n');
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 for (sp = midtk; *sp != '\0'; sp++) intoken (*sp) = TRUE;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1545 intoken('\0') = intoken('\n');
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 for (sp = endtk; *sp != '\0'; sp++) endtoken (*sp) = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 endtoken('\0') = endtoken('\n');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549
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 * This routine opens the specified file and calls the function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552 * which finds the function and type definitions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1553 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1554 node *last_node = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1555
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1556 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557 find_entries (file, inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558 char *file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1561 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1562 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1563 node *old_last_node;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1565 /* Memory leakage here: the string pointed by curfile is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1566 never released, because curfile is copied into np->file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1567 for each node, to be used in CTAGS mode. The amount of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568 memory leaked here is the sum of the lengths of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569 file names. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1570 curfile = savestr (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1572 /* If user specified a language, use it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1573 lang = forced_lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1574 if (lang != NULL && lang->function != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1575 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 curlang = lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577 lang->function (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1579 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1580
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1581 /* Try to guess the language given the file name. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1582 lang = get_language_from_filename (file);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1583 if (lang != NULL && lang->function != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1585 curlang = lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1586 lang->function (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1587 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1589
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590 /* Look for sharp-bang as the first two characters. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591 if (readline_internal (&lb, inf) > 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1592 && lb.len >= 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1593 && lb.buffer[0] == '#'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1594 && lb.buffer[1] == '!')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1596 char *lp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1598 /* 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
1599 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
1600 the first successive blank and terminate the string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1601 lp = etags_strrchr (lb.buffer+2, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1602 if (lp != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1603 lp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1604 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1605 lp = skip_spaces (lb.buffer + 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1606 cp = skip_non_spaces (lp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1607 *cp = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1608
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1609 if (strlen (lp) > 0)
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 lang = get_language_from_interpreter (lp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1612 if (lang != NULL && lang->function != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1613 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1614 curlang = lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1615 lang->function (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1616 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1617 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620 /* 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
1621 length of the first line is longer than the pipe block size,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1622 which is unlikely. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1623 rewind (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1624
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1625 /* Try Fortran. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626 old_last_node = last_node;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1627 curlang = get_language_from_langname ("fortran");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1628 Fortran_functions (inf);
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 /* No Fortran entries found. Try C. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1631 if (old_last_node == last_node)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1632 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1633 /* We do not tag if rewind fails.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1634 Only the file name will be recorded in the tags file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1635 rewind (inf);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1636 curlang = get_language_from_langname (cplusplus ? "c++" : "c");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1637 default_C_entries (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1638 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1639 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1640 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1641
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1642
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1643 /* Record a tag. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1644 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1645 pfnote (name, is_func, linestart, linelen, lno, cno)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1646 char *name; /* tag name, or NULL if unnamed */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1647 bool is_func; /* tag is a function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1648 char *linestart; /* start of the line where tag is */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1649 int linelen; /* length of the line where tag is */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1650 int lno; /* line number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1651 long cno; /* character number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1652 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653 register node *np;
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 if (CTAGS && name == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1657
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1658 np = xnew (1, node);
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 /* If ctags mode, change name "main" to M<thisfilename>. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1661 if (CTAGS && !cxref_style && streq (name, "main"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1662 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1663 register char *fp = etags_strrchr (curfile, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1664 np->name = concat ("M", fp == NULL ? curfile : fp + 1, "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1665 fp = etags_strrchr (np->name, '.');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666 if (fp != NULL && fp[1] != '\0' && fp[2] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1667 fp[0] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1668 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1669 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1670 np->name = name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671 np->been_warned = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1672 np->file = curfile;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673 np->is_func = is_func;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1674 np->lno = lno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 /* Our char numbers are 0-base, because of C language tradition?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1676 ctags compatibility? old versions compatibility? I don't know.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1677 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
1678 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
1679 uncomment the +1 below. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1680 np->cno = cno /* + 1 */ ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681 np->left = np->right = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 if (CTAGS && !cxref_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684 if (strlen (linestart) < 50)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 np->pat = concat (linestart, "$", "");
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, 50);
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1690 np->pat = savenstr (linestart, linelen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1691
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1692 add_node (np, &head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1693 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1695 /*
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1696 * TAGS format specification
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1697 * Idea by Sam Kendall <kendall@mv.mv.com> (1997)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1698 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1699 * pfnote should emit the optimized form [unnamed tag] only if:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1700 * 1. name does not contain any of the characters " \t\r\n(),;";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1701 * 2. linestart contains name as either a rightmost, or rightmost but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1702 * one character, substring;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1703 * 3. the character, if any, immediately before name in linestart must
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1704 * be one of the characters " \t(),;";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1705 * 4. the character, if any, immediately after name in linestart must
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1706 * also be one of the characters " \t(),;".
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1707 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1708 * The real implementation uses the notinname() macro, which recognises
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1709 * characters slightly different form " \t\r\n(),;". See the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1710 * `nonam'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1711 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1712 #define traditional_tag_style TRUE
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1713 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1714 new_pfnote (name, namelen, is_func, linestart, linelen, lno, cno)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1715 char *name; /* tag name, or NULL if unnamed */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1716 int namelen; /* tag length */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1717 bool is_func; /* tag is a function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1718 char *linestart; /* start of the line where tag is */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1719 int linelen; /* length of the line where tag is */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1720 int lno; /* line number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1721 long cno; /* character number */
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 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1724 bool named;
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 named = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1727 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1728 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1729 for (cp = name; !notinname (*cp); cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1730 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1731 if (*cp == '\0') /* rule #1 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1732 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1733 cp = linestart + linelen - namelen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1734 if (notinname (linestart[linelen-1]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1735 cp -= 1; /* rule #4 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1736 if (cp >= linestart /* rule #2 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1737 && (cp == linestart
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1738 || notinname (cp[-1])) /* rule #3 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1739 && strneq (name, cp, namelen)) /* rule #2 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1740 named = FALSE; /* use unnamed tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1741 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1742 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1743
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1744 if (named)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1745 name = savenstr (name, namelen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1746 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1747 name = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1748 pfnote (name, is_func, linestart, linelen, lno, cno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1749 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1750
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1751 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1752 * free_tree ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1753 * recurse on left children, iterate on right children.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1754 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1755 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1756 free_tree (np)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1757 register node *np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1758 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1759 while (np)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1760 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1761 register node *node_right = np->right;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1762 free_tree (np->left);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1763 if (np->name != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1764 free (np->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1765 free (np->pat);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1766 free (np);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1767 np = node_right;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1770
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1771 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1772 * add_node ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1773 * 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
1774 * it sorted; we just keep a linear list. In ctags mode, maintain
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1775 * an ordered tree, with no attempt at balancing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1776 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1777 * 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
1778 * maintain state.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1779 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1780 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1781 add_node (np, cur_node_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1782 node *np, **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 register int dif;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1785 register node *cur_node = *cur_node_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1786
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1787 if (cur_node == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1788 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1789 *cur_node_p = np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1790 last_node = np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1791 return;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1794 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1795 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1796 /* Etags Mode */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1797 if (last_node == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1798 fatal ("internal error in add_node", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1799 last_node->right = np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1800 last_node = np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1801 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1802 else
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 /* Ctags Mode */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1805 dif = strcmp (np->name, cur_node->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1806
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1807 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1808 * If this tag name matches an existing one, then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1809 * do not add the node, but maybe print a warning.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1810 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1811 if (!dif)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1812 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1813 if (streq (np->file, cur_node->file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1814 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1815 if (!no_warnings)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1816 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1817 fprintf (stderr, "Duplicate entry in file %s, line %d: %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1818 np->file, lineno, np->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1819 fprintf (stderr, "Second entry ignored\n");
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1822 else if (!cur_node->been_warned && !no_warnings)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1823 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1824 fprintf
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1825 (stderr,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1826 "Duplicate entry in files %s and %s: %s (Warning only)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1827 np->file, cur_node->file, np->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1828 cur_node->been_warned = TRUE;
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 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1831 }
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 /* Actually add the node */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1834 add_node (np, dif < 0 ? &cur_node->left : &cur_node->right);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1835 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1836 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1837
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1838
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1839 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1840 put_entries (np)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1841 register node *np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1842 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1843 register char *sp;
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 if (np == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1846 return;
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 subentries that precede this one */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1849 put_entries (np->left);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1850
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1851 /* Output this entry */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1852
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1853 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1854 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1855 if (np->name != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1856 fprintf (tagf, "%s\177%s\001%d,%ld\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1857 np->pat, np->name, np->lno, np->cno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1858 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1859 fprintf (tagf, "%s\177%d,%ld\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1860 np->pat, np->lno, np->cno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1861 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1862 else
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 (np->name == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1865 error ("internal error: NULL name in ctags mode.", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1866
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1867 if (cxref_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1868 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1869 if (vgrind_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1870 fprintf (stdout, "%s %s %d\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1871 np->name, np->file, (np->lno + 63) / 64);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1872 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1873 fprintf (stdout, "%-16s %3d %-16s %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1874 np->name, np->lno, np->file, np->pat);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1875 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1876 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1877 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1878 fprintf (tagf, "%s\t%s\t", np->name, np->file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1879
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1880 if (np->is_func)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1881 { /* a function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1882 putc (searchar, tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1883 putc ('^', tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1884
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1885 for (sp = np->pat; *sp; sp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1886 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1887 if (*sp == '\\' || *sp == searchar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1888 putc ('\\', tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1889 putc (*sp, tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1890 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1891 putc (searchar, tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1892 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1893 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1894 { /* a typedef; text pattern inadequate */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1895 fprintf (tagf, "%d", np->lno);
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 putc ('\n', tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1898 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1899 }
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 /* Output subentries that follow this one */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1902 put_entries (np->right);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1903 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1904
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1905 /* Length of a number's decimal representation. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1906 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1907 number_len (num)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1908 long num;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1909 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1910 int len = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1911 while ((num /= 10) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1912 len += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1913 return len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1914 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1915
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1916 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1917 * Return total number of characters that put_entries will output for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1918 * the nodes in the subtree of the specified node. Works only if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1919 * we are not ctags, but called only in that case. This count
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1920 * is irrelevant with the new tags.el, but is still supplied for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1921 * backward compatibility.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1922 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1923 static int
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1924 total_size_of_entries (np)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1925 register node *np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1926 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1927 register int total;
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 if (np == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1930 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1931
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1932 for (total = 0; np != NULL; np = np->right)
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 left subentries. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1935 total += total_size_of_entries (np->left);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1936
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1937 /* Count this entry */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1938 total += strlen (np->pat) + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1939 total += number_len ((long) np->lno) + 1 + number_len (np->cno) + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1940 if (np->name != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1941 total += 1 + strlen (np->name); /* \001name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1942 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1943
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1944 return total;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1945 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1946
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1947
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1948 /* C extensions. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1949 #define C_EXT 0x00fff /* C extensions */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1950 #define C_PLAIN 0x00000 /* C */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1951 #define C_PLPL 0x00001 /* C++ */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1952 #define C_STAR 0x00003 /* C* */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1953 #define C_JAVA 0x00005 /* JAVA */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1954 #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
1955 #define YACC 0x10000 /* yacc file */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1956
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1957 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1958 * The C symbol tables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1959 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1960 enum sym_type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1961 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1962 st_none,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1963 st_C_objprot, st_C_objimpl, st_C_objend,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1964 st_C_gnumacro,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1965 st_C_ignore,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1966 st_C_javastruct,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1967 st_C_operator,
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
1968 st_C_class, st_C_template,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1969 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
1970 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1971
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
1972 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
1973 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
1974 static enum sym_type C_symtype __P((char *, int, int));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1975
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1976 /* Feed stuff between (but not including) %[ and %] lines to:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1977 gperf -c -k 1,3 -o -p -r -t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1978 %[
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1979 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
1980 %%
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1981 if, 0, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1982 for, 0, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1983 while, 0, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1984 switch, 0, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1985 return, 0, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1986 @interface, 0, st_C_objprot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1987 @protocol, 0, st_C_objprot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1988 @implementation,0, st_C_objimpl
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1989 @end, 0, st_C_objend
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1990 import, C_JAVA, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1991 package, C_JAVA, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1992 friend, C_PLPL, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1993 extends, C_JAVA, st_C_javastruct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1994 implements, C_JAVA, st_C_javastruct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1995 interface, C_JAVA, st_C_struct
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1996 class, 0, st_C_class
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1997 namespace, C_PLPL, st_C_struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1998 domain, C_STAR, st_C_struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1999 union, 0, st_C_struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2000 struct, 0, st_C_struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2001 extern, 0, st_C_extern
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2002 enum, 0, st_C_enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2003 typedef, 0, st_C_typedef
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2004 define, 0, st_C_define
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2005 operator, C_PLPL, st_C_operator
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2006 template, 0, st_C_template
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2007 bool, C_PLPL, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2008 long, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2009 short, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2010 int, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2011 char, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2012 float, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2013 double, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2014 signed, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2015 unsigned, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2016 auto, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2017 void, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2018 static, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2019 const, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2020 volatile, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2021 explicit, C_PLPL, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2022 mutable, C_PLPL, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2023 typename, C_PLPL, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2024 # 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
2025 DEFUN, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2026 SYSCALL, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2027 ENTRY, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2028 PSEUDO, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2029 # These are defined inside C functions, so currently they are not met.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2030 # EXFUN used in glibc, DEFVAR_* in emacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2031 #EXFUN, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2032 #DEFVAR_, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2033 %]
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2034 and replace lines between %< and %> with its output,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2035 then make in_word_set static. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2036 /*%<*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2037 /* C code produced by gperf version 2.7.1 (19981006 egcs) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2038 /* Command-line: gperf -c -k 1,3 -o -p -r -t */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2039 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
2040
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2041 #define TOTAL_KEYWORDS 47
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2042 #define MIN_WORD_LENGTH 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2043 #define MAX_WORD_LENGTH 15
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2044 #define MIN_HASH_VALUE 18
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2045 #define MAX_HASH_VALUE 138
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2046 /* maximum key range = 121, duplicates = 0 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2047
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2048 #ifdef __GNUC__
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2049 __inline
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2050 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2051 static unsigned int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2052 hash (str, len)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2053 register const char *str;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2054 register unsigned int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2055 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2056 static unsigned char asso_values[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2057 {
531
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, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2062 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
2063 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
2064 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
2065 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
2066 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
2067 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
2068 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
2069 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
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, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2081 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
2082 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
2083 139, 139, 139, 139, 139, 139
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2084 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2085 register int hval = len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2086
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2087 switch (hval)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2088 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2089 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2090 case 3:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2091 hval += asso_values[(unsigned char)str[2]];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2092 case 2:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2093 case 1:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2094 hval += asso_values[(unsigned char)str[0]];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2095 break;
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 return hval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2098 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2099
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2100 #ifdef __GNUC__
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2101 __inline
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2102 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2103 static struct C_stab_entry *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2104 in_word_set (str, len)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2105 register const char *str;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2106 register unsigned int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2107 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2108 static struct C_stab_entry wordlist[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2109 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2110 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2111 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2112 {"if", 0, st_C_ignore},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2113 {""}, {""}, {""}, {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2114 {"int", 0, st_C_typespec},
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2115 {""}, {""},
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2116 {"void", 0, st_C_typespec},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2117 {""}, {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2118 {"interface", C_JAVA, st_C_struct},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2119 {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2120 {"SYSCALL", 0, st_C_gnumacro},
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2121 {""},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2122 {"return", 0, st_C_ignore},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2123 {""}, {""}, {""}, {""}, {""}, {""}, {""},
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2124 {"while", 0, st_C_ignore},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2125 {"auto", 0, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2126 {""}, {""}, {""}, {""}, {""}, {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2127 {"float", 0, st_C_typespec},
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2128 {"typedef", 0, st_C_typedef},
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2129 {"typename", C_PLPL, st_C_typespec},
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2130 {""}, {""}, {""},
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2131 {"friend", C_PLPL, st_C_ignore},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2132 {"volatile", 0, st_C_typespec},
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2133 {""}, {""},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2134 {"for", 0, st_C_ignore},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2135 {"const", 0, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2136 {"import", C_JAVA, st_C_ignore},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2137 {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2138 {"define", 0, st_C_define},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2139 {"long", 0, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2140 {"implements", C_JAVA, st_C_javastruct},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2141 {"signed", 0, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2142 {""},
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2143 {"extern", 0, st_C_extern},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2144 {"extends", C_JAVA, st_C_javastruct},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2145 {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2146 {"mutable", C_PLPL, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2147 {"template", 0, st_C_template},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2148 {"short", 0, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2149 {"bool", C_PLPL, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2150 {"char", 0, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2151 {"class", 0, st_C_class},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2152 {"operator", C_PLPL, st_C_operator},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2153 {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2154 {"switch", 0, st_C_ignore},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2155 {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2156 {"ENTRY", 0, st_C_gnumacro},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2157 {""},
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2158 {"package", C_JAVA, st_C_ignore},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2159 {"union", 0, st_C_struct},
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2160 {"@end", 0, st_C_objend},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2161 {"struct", 0, st_C_struct},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2162 {"namespace", C_PLPL, st_C_struct},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2163 {""}, {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2164 {"domain", C_STAR, st_C_struct},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2165 {"@interface", 0, st_C_objprot},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2166 {"PSEUDO", 0, st_C_gnumacro},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2167 {"double", 0, st_C_typespec},
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2168 {""},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2169 {"@protocol", 0, st_C_objprot},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2170 {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2171 {"static", 0, st_C_typespec},
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2172 {""}, {""},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2173 {"DEFUN", 0, st_C_gnumacro},
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 {"explicit", C_PLPL, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2176 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2177 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2178 {""},
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2179 {"enum", 0, st_C_enum},
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2180 {""}, {""},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2181 {"unsigned", 0, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2182 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2183 {"@implementation",0, st_C_objimpl}
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2186 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2187 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2188 register int key = hash (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2189
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2190 if (key <= MAX_HASH_VALUE && key >= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2191 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2192 register const char *s = wordlist[key].name;
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 if (*str == *s && !strncmp (str + 1, s + 1, len - 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2195 return &wordlist[key];
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 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2199 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2200 /*%>*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2201
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2202 static enum sym_type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2203 C_symtype (str, len, c_ext)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2204 char *str;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2205 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2206 int c_ext;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2207 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2208 register struct C_stab_entry *se = in_word_set (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2209
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2210 if (se == NULL || (se->c_ext && !(c_ext & se->c_ext)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2211 return st_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2212 return se->type;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2213 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2214
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2215
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2216 /*
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2217 * C functions and variables are recognized using a simple
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2218 * finite automaton. fvdef is its state variable.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2219 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2220 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2221 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2222 fvnone, /* nothing seen */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2223 fdefunkey, /* Emacs DEFUN keyword seen */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2224 fdefunname, /* Emacs DEFUN name seen */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2225 foperator, /* func: operator keyword seen (cplpl) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2226 fvnameseen, /* function or variable name seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2227 fstartlist, /* func: just after open parenthesis */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2228 finlist, /* func: in parameter list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2229 flistseen, /* func: after parameter list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2230 fignore, /* func: before open brace */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2231 vignore /* var-like: ignore until ';' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2232 } fvdef;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2234 bool fvextern; /* func or var: extern keyword seen; */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2235
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2236 /*
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2237 * typedefs are recognized using a simple finite automaton.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2238 * typdef is its state variable.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2239 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2240 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2241 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2242 tnone, /* nothing seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2243 tkeyseen, /* typedef keyword seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2244 ttypeseen, /* defined type seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2245 tinbody, /* inside typedef body */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2246 tend, /* just before typedef tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2247 tignore /* junk after typedef tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2248 } typdef;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2249
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2250 /*
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2251 * struct-like structures (enum, struct and union) are recognized
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2252 * using another simple finite automaton. `structdef' is its state
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2253 * variable.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2254 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2255 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2256 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2257 snone, /* nothing seen yet,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2258 or in struct body if cblev > 0 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2259 skeyseen, /* struct-like keyword seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2260 stagseen, /* struct-like tag seen */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2261 sintemplate, /* inside template (ignore) */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2262 scolonseen /* colon seen after struct-like tag */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2263 } structdef;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2266 * 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
2267 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2268 char *objtag = "<uninited>";
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2271 * Yet another little state machine to deal with preprocessor lines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2272 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2273 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2274 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2275 dnone, /* nothing seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2276 dsharpseen, /* '#' seen as first char on line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2277 ddefineseen, /* '#' and 'define' seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2278 dignorerest /* ignore rest of line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2279 } definedef;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2280
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 * State machine for Objective C protocols and implementations.
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2283 * Idea by Tom R.Hageman <tom@basil.icce.rug.nl> (1995)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2284 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2285 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2286 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2287 onone, /* nothing seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2288 oprotocol, /* @interface or @protocol seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2289 oimplementation, /* @implementations seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2290 otagseen, /* class name seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2291 oparenseen, /* parenthesis before category seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2292 ocatseen, /* category name seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2293 oinbody, /* in @implementation body */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2294 omethodsign, /* in @implementation body, after +/- */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2295 omethodtag, /* after method name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2296 omethodcolon, /* after method colon */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2297 omethodparm, /* after method parameter */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2298 oignore /* wait for @end */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2299 } objdef;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2300
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2301
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2302 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2303 * 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
2304 * 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
2305 */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2306 struct tok
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2307 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2308 bool valid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2309 bool named;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2310 int offset;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2311 int length;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2312 int lineno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2313 long linepos;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2314 char *line;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2315 } token; /* latest token read */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2316 linebuffer token_name; /* its name */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2317
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2318 /*
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2319 * Variables and functions for dealing with nested structures.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2320 * Idea by Mykola Dzyuba <mdzyuba@yahoo.com> (2001)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2321 */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
2322 static void pushclass_above __P((int, char *, int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
2323 static void popclass_above __P((int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
2324 static void write_classname __P((linebuffer *, char *qualifier));
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2325
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2326 struct {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2327 char **cname; /* nested class names */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2328 int *cblev; /* nested class curly brace level */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2329 int nl; /* class nesting level (elements used) */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2330 int size; /* length of the array */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2331 } cstack; /* stack for nested declaration tags */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2332 /* Current struct nesting depth (namespace, class, struct, union, enum). */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2333 #define nestlev (cstack.nl)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2334 /* 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
2335 #define instruct (structdef == snone && nestlev > 0 \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2336 && cblev == cstack.cblev[nestlev-1] + 1)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2337
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2338 static void
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2339 pushclass_above (cblev, str, len)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2340 int cblev;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2341 char *str;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2342 int len;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2343 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2344 int nl;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2345
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2346 popclass_above (cblev);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2347 nl = cstack.nl;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2348 if (nl >= cstack.size)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2349 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2350 int size = cstack.size *= 2;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2351 xrnew (cstack.cname, size, char *);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2352 xrnew (cstack.cblev, size, int);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2353 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2354 assert (nl == 0 || cstack.cblev[nl-1] < cblev);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2355 cstack.cname[nl] = (str == NULL) ? NULL : savenstr (str, len);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2356 cstack.cblev[nl] = cblev;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2357 cstack.nl = nl + 1;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2358 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2359
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2360 static void
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2361 popclass_above (cblev)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2362 int cblev;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2363 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2364 int nl;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2365
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2366 for (nl = cstack.nl - 1;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2367 nl >= 0 && cstack.cblev[nl] >= cblev;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2368 nl--)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2369 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2370 if (cstack.cname[nl] != NULL)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2371 free (cstack.cname[nl]);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2372 cstack.nl = nl;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2373 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2374 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2375
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2376 static void
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2377 write_classname (cn, qualifier)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2378 linebuffer *cn;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2379 char *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 int i, len;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2382 int qlen = strlen (qualifier);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2383
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2384 if (cstack.nl == 0 || cstack.cname[0] == NULL)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2385 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2386 len = 0;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2387 cn->len = 0;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2388 cn->buffer[0] = '\0';
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2389 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2390 else
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2391 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2392 len = strlen (cstack.cname[0]);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2393 linebuffer_setlen (cn, len);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2394 strcpy (cn->buffer, cstack.cname[0]);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2395 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2396 for (i = 1; i < cstack.nl; i++)
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 char *s;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2399 int slen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2400
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2401 s = cstack.cname[i];
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2402 if (s == NULL)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2403 continue;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2404 slen = strlen (s);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2405 len += slen + qlen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2406 linebuffer_setlen (cn, len);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2407 strncat (cn->buffer, qualifier, qlen);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2408 strncat (cn->buffer, s, slen);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2409 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2410 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2411
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2412
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
2413 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
2414 static void make_C_tag __P((bool));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
2415
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2416 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2417 * consider_token ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2418 * 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
2419 * function or variable, or corresponds to a typedef, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2420 * is a struct/union/enum tag, or #define, or an enum constant.
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 * *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
2423 * 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
2424 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2425 * Globals
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2426 * fvdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2427 * structdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2428 * definedef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2429 * typdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2430 * objdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2431 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2432
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2433 static bool
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2434 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
2435 register char *str; /* IN: token pointer */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2436 register int len; /* IN: token length */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
2437 register int c; /* IN: first char after the token */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2438 int *c_extp; /* IN, OUT: C extensions mask */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2439 int cblev; /* IN: curly brace level */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2440 int parlev; /* IN: parenthesis level */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2441 bool *is_func_or_var; /* OUT: function or variable found */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2442 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2443 /* When structdef is stagseen, scolonseen, or snone with cblev > 0,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2444 structtype is the type of the preceding struct-like keyword, and
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2445 structcblev is the curly brace level where it has been seen. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2446 static enum sym_type structtype;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2447 static int structcblev;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2448 static enum sym_type toktype;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2449
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2450
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2451 toktype = C_symtype (str, len, *c_extp);
428
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2454 * Advance the definedef state machine.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2455 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2456 switch (definedef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2457 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2458 case dnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2459 /* We're not on a preprocessor line. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2460 if (toktype == st_C_gnumacro)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2461 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2462 fvdef = fdefunkey;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2463 return FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2464 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2465 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2466 case dsharpseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2467 if (toktype == st_C_define)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2468 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2469 definedef = ddefineseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2470 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2471 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2472 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2473 definedef = dignorerest;
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 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2476 case ddefineseen:
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 * Make a tag for any macro, unless it is a constant
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2479 * and constantypedefs is FALSE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2480 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2481 definedef = dignorerest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2482 *is_func_or_var = (c == '(');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2483 if (!*is_func_or_var && !constantypedefs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2484 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2485 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2486 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2487 case dignorerest:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2488 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2489 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2490 error ("internal error: definedef value.", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2491 }
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2494 * Now typedefs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2495 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2496 switch (typdef)
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 case tnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2499 if (toktype == st_C_typedef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2500 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2501 if (typedefs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2502 typdef = tkeyseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2503 fvextern = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2504 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2505 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2506 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2507 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2508 case tkeyseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2509 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2510 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2511 case st_none:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2512 case st_C_typespec:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2513 case st_C_class:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2514 case st_C_struct:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2515 case st_C_enum:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2516 typdef = ttypeseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2517 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2518 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2519 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2520 case ttypeseen:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2521 if (structdef == snone && fvdef == fvnone)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2522 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2523 fvdef = fvnameseen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2524 return TRUE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2525 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2526 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2527 case tend:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2528 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2529 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2530 case st_C_typespec:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2531 case st_C_class:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2532 case st_C_struct:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2533 case st_C_enum:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2534 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2535 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2536 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2537 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2538
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2539 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2540 * This structdef business is NOT invoked when we are ctags and the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2541 * 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
2542 * name as another tag, and this loses with ctags.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2543 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2544 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2545 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2546 case st_C_javastruct:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2547 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2548 structdef = scolonseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2549 return FALSE;
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2550 case st_C_template:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2551 case st_C_class:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2552 if (cblev == 0
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2553 && (*c_extp & C_AUTO) /* automatic detection of C++ language */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2554 && definedef == dnone && structdef == snone
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2555 && typdef == tnone && fvdef == fvnone)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2556 *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
2557 if (toktype == st_C_template)
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2558 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2559 /* FALLTHRU */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2560 case st_C_struct:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2561 case st_C_enum:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2562 if (parlev == 0
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2563 && fvdef != vignore
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2564 && (typdef == tkeyseen
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2565 || (typedefs_or_cplusplus && structdef == snone)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2566 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2567 structdef = skeyseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2568 structtype = toktype;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2569 structcblev = cblev;
428
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 return FALSE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2574 if (structdef == skeyseen)
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 structdef = stagseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2577 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2578 }
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 if (typdef != tnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2581 definedef = dnone;
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 /* Detect Objective C constructs. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2584 switch (objdef)
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 onone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2587 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2588 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2589 case st_C_objprot:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2590 objdef = oprotocol;
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 case st_C_objimpl:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2593 objdef = oimplementation;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2594 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2595 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2596 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2597 case oimplementation:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2598 /* Save the class tag for functions or variables defined inside. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2599 objtag = savenstr (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2600 objdef = oinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2601 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2602 case oprotocol:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2603 /* Save the class tag for categories. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2604 objtag = savenstr (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2605 objdef = otagseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2606 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2607 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2608 case oparenseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2609 objdef = ocatseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2610 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2611 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2612 case oinbody:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2613 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2614 case omethodsign:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2615 if (parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2616 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2617 objdef = omethodtag;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2618 linebuffer_setlen (&token_name, len);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2619 strncpy (token_name.buffer, str, len);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2620 token_name.buffer[len] = '\0';
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2621 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2622 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2623 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2624 case omethodcolon:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2625 if (parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2626 objdef = omethodparm;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2627 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2628 case omethodparm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2629 if (parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2630 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2631 objdef = omethodtag;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2632 linebuffer_setlen (&token_name, token_name.len + len);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2633 strncat (token_name.buffer, str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2634 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2635 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2636 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2637 case oignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2638 if (toktype == st_C_objend)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2639 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2640 /* Memory leakage here: the string pointed by objtag is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2641 never released, because many tests would be needed to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2642 avoid breaking on incorrect input code. The amount of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2643 memory leaked here is the sum of the lengths of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2644 class tags.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2645 free (objtag); */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2646 objdef = onone;
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 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2649 }
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 /* A function, variable or enum constant? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2652 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2653 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2654 case st_C_extern:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2655 fvextern = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2656 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2657 case st_C_typespec:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2658 if (fvdef != finlist && fvdef != fignore && fvdef != vignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2659 fvdef = fvnone; /* should be useless */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2660 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2661 case st_C_ignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2662 fvextern = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2663 fvdef = vignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2664 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2665 case st_C_operator:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2666 fvdef = foperator;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2667 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2668 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2669 case st_none:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2670 if (constantypedefs
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2671 && structdef == snone
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2672 && structtype == st_C_enum && cblev > structcblev)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2673 return TRUE; /* enum constant */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2674 switch (fvdef)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2675 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2676 case fdefunkey:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2677 if (cblev > 0)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2678 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2679 fvdef = fdefunname; /* GNU macro */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2680 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2681 return TRUE;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2682 case fvnone:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2683 if ((strneq (str, "asm", 3) && endtoken (str[3]))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2684 || (strneq (str, "__asm__", 7) && endtoken (str[7])))
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 fvdef = vignore;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2687 return FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2688 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2689 if ((*c_extp & C_PLPL) && strneq (str+len-10, "::operator", 10))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2690 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2691 fvdef = foperator;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2692 *is_func_or_var = TRUE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2693 return TRUE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2694 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2695 if (cblev > 0 && !instruct)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2696 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2697 fvdef = fvnameseen; /* function or variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2698 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2699 return TRUE;
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 break;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2704 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2705 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2706
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2707
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2708 /*
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2709 * 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
2710 * the line currently read. By keeping two line buffers, and switching
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2711 * 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
2712 */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2713 struct
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2714 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2715 long linepos;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2716 linebuffer lb;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2717 } lbs[2];
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2718
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2719 #define current_lb_is_new (newndx == curndx)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2720 #define switch_line_buffers() (curndx = 1 - curndx)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2721
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2722 #define curlb (lbs[curndx].lb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2723 #define newlb (lbs[newndx].lb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2724 #define curlinepos (lbs[curndx].linepos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2725 #define newlinepos (lbs[newndx].linepos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2726
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2727 #define CNL_SAVE_DEFINEDEF() \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2728 do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2729 curlinepos = charno; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2730 lineno++; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2731 linecharno = charno; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2732 charno += readline (&curlb, inf); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2733 lp = curlb.buffer; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2734 quotednl = FALSE; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2735 newndx = curndx; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2736 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2737
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2738 #define CNL() \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2739 do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2740 CNL_SAVE_DEFINEDEF(); \
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2741 if (savetoken.valid) \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2742 { \
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2743 token = savetoken; \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2744 savetoken.valid = FALSE; \
428
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 definedef = dnone; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2747 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2748
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2749
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2750 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2751 make_C_tag (isfun)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2752 bool isfun;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2753 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2754 /* 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
2755 we must protect against invalid input or internal errors. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2756 if (DEBUG || token.valid)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2757 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2758 if (traditional_tag_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2759 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2760 /* This was the original code. Now we call new_pfnote instead,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2761 which uses the new method for naming tags (see new_pfnote). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2762 char *name = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2763
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2764 if (CTAGS || token.named)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2765 name = savestr (token_name.buffer);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2766 if (DEBUG && !token.valid)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2767 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2768 if (token.named)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2769 name = concat (name, "##invalid##", "");
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2770 else
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2771 name = savestr ("##invalid##");
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2772 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2773 pfnote (name, isfun, token.line,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2774 token.offset+token.length+1, token.lineno, token.linepos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2775 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2776 else
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2777 new_pfnote (token_name.buffer, token_name.len, isfun, token.line,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2778 token.offset+token.length+1, token.lineno, token.linepos);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2779 token.valid = FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2780 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2781 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2782
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2783
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2784 /*
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2785 * C_entries ()
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2786 * This routine finds functions, variables, typedefs,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2787 * #define's, enum constants and struct/union/enum definitions in
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2788 * C syntax and adds them to the list.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2789 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
2790 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2791 C_entries (c_ext, inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2792 int c_ext; /* extension of C */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2793 FILE *inf; /* input file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2794 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2795 register char c; /* latest char read; '\0' for end of line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2796 register char *lp; /* pointer one beyond the character `c' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2797 int curndx, newndx; /* indices for current and new lb */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2798 register int tokoff; /* offset in line of start of current token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2799 register int toklen; /* length of current token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2800 char *qualifier; /* string used to qualify names */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2801 int qlen; /* length of qualifier */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2802 int cblev; /* current curly brace level */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2803 int parlev; /* current parenthesis level */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2804 int typdefcblev; /* cblev where a typedef struct body begun */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2805 bool incomm, inquote, inchar, quotednl, midtoken;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2806 bool cplpl, cjava;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2807 bool yacc_rules; /* in the rules part of a yacc file */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2808 struct tok savetoken; /* token saved during preprocessor handling */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2809
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2810
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2811 initbuffer (&token_name);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2812 initbuffer (&lbs[0].lb);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2813 initbuffer (&lbs[1].lb);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2814 if (cstack.size == 0)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2815 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2816 cstack.size = (DEBUG) ? 1 : 4;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2817 cstack.nl = 0;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2818 cstack.cname = xnew (cstack.size, char *);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2819 cstack.cblev = xnew (cstack.size, int);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2820 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2821
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2822 tokoff = toklen = typdefcblev = 0; /* keep compiler quiet */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2823 curndx = newndx = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2824 lineno = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2825 charno = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2826 lp = curlb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2827 *lp = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2828
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2829 fvdef = fvnone; fvextern = FALSE; typdef = tnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2830 structdef = snone; definedef = dnone; objdef = onone;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2831 yacc_rules = FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2832 midtoken = inquote = inchar = incomm = quotednl = FALSE;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2833 token.valid = savetoken.valid = FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2834 cblev = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2835 parlev = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2836 cplpl = (c_ext & C_PLPL) == C_PLPL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2837 cjava = (c_ext & C_JAVA) == C_JAVA;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2838 if (cjava)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2839 { qualifier = "."; qlen = 1; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2840 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2841 { qualifier = "::"; qlen = 2; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2842
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2843
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2844 while (!feof (inf))
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 c = *lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2847 if (c == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2848 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2849 /* 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
2850 '\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
2851 to read the next line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2852 if (*lp == '\0')
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 quotednl = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2855 continue;
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 lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2858 c = ' ';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2859 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2860 else if (incomm)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2861 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2862 switch (c)
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 case '*':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2865 if (*lp == '/')
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 c = *lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2868 incomm = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2869 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2870 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2871 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2872 /* Newlines inside comments do not end macro definitions in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2873 traditional cpp. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2874 CNL_SAVE_DEFINEDEF ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2875 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2876 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2877 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2878 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2879 else if (inquote)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2880 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2881 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2882 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2883 case '"':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2884 inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2885 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2886 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2887 /* Newlines inside strings do not end macro definitions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2888 in traditional cpp, even though compilers don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2889 usually accept them. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2890 CNL_SAVE_DEFINEDEF ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2891 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2892 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2893 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2894 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2895 else if (inchar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2896 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2897 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2898 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2899 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2900 /* Hmmm, something went wrong. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2901 CNL ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2902 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2903 case '\'':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2904 inchar = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2905 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2906 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2907 continue;
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2910 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2911 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2912 case '"':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2913 inquote = TRUE;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2914 switch (fvdef)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2915 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2916 case fdefunkey:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2917 case fstartlist:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2918 case finlist:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2919 case fignore:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2920 case vignore:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2921 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2922 default:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2923 fvextern = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2924 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2925 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2926 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2927 case '\'':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2928 inchar = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2929 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore)
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 fvextern = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2932 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2933 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2934 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2935 case '/':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2936 if (*lp == '*')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2937 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2938 lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2939 incomm = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2940 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2941 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2942 else if (/* cplpl && */ *lp == '/')
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 c = '\0';
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2947 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2948 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2949 case '%':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2950 if ((c_ext & YACC) && *lp == '%')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2951 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2952 /* Entering or exiting rules section in yacc file. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2953 lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2954 definedef = dnone; fvdef = fvnone; fvextern = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2955 typdef = tnone; structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2956 midtoken = inquote = inchar = incomm = quotednl = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2957 cblev = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2958 yacc_rules = !yacc_rules;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2959 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2960 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2961 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2962 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2963 case '#':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2964 if (definedef == dnone)
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 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2967 bool cpptoken = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2968
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2969 /* Look back on this line. If all blanks, or nonblanks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2970 followed by an end of comment, this is a preprocessor
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2971 token. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2972 for (cp = newlb.buffer; cp < lp-1; cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2973 if (!iswhite (*cp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2974 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2975 if (*cp == '*' && *(cp+1) == '/')
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 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2978 cpptoken = TRUE;
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2981 cpptoken = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2982 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2983 if (cpptoken)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2984 definedef = dsharpseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2985 } /* if (definedef == dnone) */
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 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2988 } /* switch (c) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2989
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2990
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2991 /* Consider token only if some involved conditions are satisfied. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2992 if (typdef != tignore
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2993 && definedef != dignorerest
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2994 && fvdef != finlist
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2995 && structdef != sintemplate
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2996 && (definedef != dnone
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2997 || structdef != scolonseen))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2998 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2999 if (midtoken)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3000 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3001 if (endtoken (c))
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 if (c == ':' && cplpl && *lp == ':' && begtoken (lp[1]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3004 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3005 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3006 * This handles :: in the middle, but not at the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3007 * beginning of an identifier. Also, space-separated
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3008 * :: is not recognised.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3009 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3010 lp += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3011 toklen += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3012 c = lp[-1];
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3013 goto still_in_token;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3014 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3015 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3016 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3017 bool funorvar = FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3018
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3019 if (yacc_rules
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3020 || consider_token (newlb.buffer + tokoff, toklen, c,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3021 &c_ext, cblev, parlev, &funorvar))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3022 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3023 if (fvdef == foperator)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3024 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3025 char *oldlp = lp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3026 lp = skip_spaces (lp-1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3027 if (*lp != '\0')
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 while (*lp != '\0'
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3030 && !iswhite (*lp) && *lp != '(')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3031 lp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3032 c = *lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3033 toklen += lp - oldlp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3034 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3035 token.named = FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3036 if ((c_ext & C_EXT) /* not pure C */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3037 && nestlev > 0 && definedef == dnone)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3038 /* in struct body */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3039 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3040 write_classname (&token_name, qualifier);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3041 linebuffer_setlen (&token_name,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3042 token_name.len+qlen+toklen);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3043 strcat (token_name.buffer, qualifier);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3044 strncat (token_name.buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3045 newlb.buffer + tokoff, toklen);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3046 token.named = TRUE;
428
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 else if (objdef == ocatseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3049 /* Objective C category */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3050 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3051 int len = strlen (objtag) + 2 + toklen;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3052 linebuffer_setlen (&token_name, len);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3053 strcpy (token_name.buffer, objtag);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3054 strcat (token_name.buffer, "(");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3055 strncat (token_name.buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3056 newlb.buffer + tokoff, toklen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3057 strcat (token_name.buffer, ")");
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3058 token.named = TRUE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3059 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3060 else if (objdef == omethodtag
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3061 || objdef == omethodparm)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3062 /* Objective C method */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3063 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3064 token.named = TRUE;
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 else if (fvdef == fdefunname)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3067 /* GNU DEFUN and similar macros */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3068 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3069 bool defun = (newlb.buffer[tokoff] == 'F');
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3070 int off = tokoff;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3071 int len = toklen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3072
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3073 /* Rewrite the tag so that emacs lisp DEFUNs
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3074 can be found by their elisp name */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3075 if (defun)
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 off += 1;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3078 len -= 1;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3079 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3080 len = toklen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3081 linebuffer_setlen (&token_name, len);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3082 strncpy (token_name.buffer,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3083 newlb.buffer + off, len);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3084 token_name.buffer[len] = '\0';
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3085 if (defun)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3086 while (--len >= 0)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3087 if (token_name.buffer[len] == '_')
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3088 token_name.buffer[len] = '-';
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3089 token.named = defun;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3090 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3091 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3092 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3093 linebuffer_setlen (&token_name, toklen);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3094 strncpy (token_name.buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3095 newlb.buffer + tokoff, toklen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3096 token_name.buffer[toklen] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3097 /* Name macros and members. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3098 token.named = (structdef == stagseen
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3099 || typdef == ttypeseen
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3100 || typdef == tend
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3101 || (funorvar
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3102 && definedef == dignorerest)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3103 || (funorvar
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3104 && definedef == dnone
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3105 && structdef == snone
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3106 && cblev > 0));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3107 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3108 token.lineno = lineno;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3109 token.offset = tokoff;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3110 token.length = toklen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3111 token.line = newlb.buffer;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3112 token.linepos = newlinepos;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3113 token.valid = TRUE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3114
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3115 if (definedef == dnone
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3116 && (fvdef == fvnameseen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3117 || fvdef == foperator
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3118 || structdef == stagseen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3119 || typdef == tend
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3120 || typdef == ttypeseen
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3121 || objdef != onone))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3122 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3123 if (current_lb_is_new)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3124 switch_line_buffers ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3125 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3126 else if (definedef != dnone
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3127 || fvdef == fdefunname
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3128 || instruct)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3129 make_C_tag (funorvar);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3130 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3131 midtoken = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3132 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3133 } /* if (endtoken (c)) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3134 else if (intoken (c))
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3135 still_in_token:
428
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 toklen++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3138 continue;
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 } /* if (midtoken) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3141 else if (begtoken (c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3142 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3143 switch (definedef)
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 dnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3146 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3147 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3148 case fstartlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3149 fvdef = finlist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3150 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3151 case flistseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3152 make_C_tag (TRUE); /* a function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3153 fvdef = fignore;
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 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3156 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3157 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3158 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3159 if (structdef == stagseen && !cjava)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3160 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3161 popclass_above (cblev);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3162 structdef = snone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3163 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3164 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3165 case dsharpseen:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3166 savetoken = token;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3167 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3168 if (!yacc_rules || lp == newlb.buffer + 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3169 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3170 tokoff = lp - 1 - newlb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3171 toklen = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3172 midtoken = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3173 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3174 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3175 } /* if (begtoken) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3176 } /* if must look at token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3177
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3178
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3179 /* Detect end of line, colon, comma, semicolon and various braces
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3180 after having handled a token.*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3181 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3182 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3183 case ':':
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3184 if (yacc_rules && token.offset == 0 && token.valid)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3185 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3186 make_C_tag (FALSE); /* a yacc function */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3187 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3188 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3189 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3190 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3191 switch (objdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3192 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3193 case otagseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3194 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3195 make_C_tag (TRUE); /* an Objective C class */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3196 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3197 case omethodtag:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3198 case omethodparm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3199 objdef = omethodcolon;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3200 linebuffer_setlen (&token_name, token_name.len + 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3201 strcat (token_name.buffer, ":");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3202 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3203 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3204 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3205 structdef = scolonseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3206 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3207 case ';':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3208 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3209 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3210 switch (typdef)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3211 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3212 case tend:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3213 case ttypeseen:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3214 make_C_tag (FALSE); /* a typedef */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3215 typdef = tnone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3216 fvdef = fvnone;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3217 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3218 case tnone:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3219 case tinbody:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3220 case tignore:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3221 switch (fvdef)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3222 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3223 case fignore:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3224 if (typdef == tignore)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3225 fvdef = fvnone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3226 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3227 case fvnameseen:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3228 if ((globals && cblev == 0 && (!fvextern || declarations))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3229 || (members && instruct))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3230 make_C_tag (FALSE); /* a variable */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3231 fvextern = FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3232 fvdef = fvnone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3233 token.valid = FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3234 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3235 case flistseen:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3236 if ((declarations && typdef == tnone && !instruct)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3237 || (members && typdef != tignore && instruct))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3238 make_C_tag (TRUE); /* a function declaration */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3239 /* FALLTHRU */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3240 default:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3241 fvextern = FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3242 fvdef = fvnone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3243 if (declarations
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3244 && structdef == stagseen && (c_ext & C_PLPL))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3245 make_C_tag (FALSE); /* forward declaration */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3246 else
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3247 /* The following instruction invalidates the token.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3248 Probably the token should be invalidated in all other
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3249 cases where some state machine is reset prematurely. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3250 token.valid = FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3251 } /* switch (fvdef) */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3252 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3253 default:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3254 if (!instruct)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3255 typdef = tnone;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3256 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3257 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3258 structdef = snone;
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 case ',':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3261 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3262 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3263 switch (objdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3264 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3265 case omethodtag:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3266 case omethodparm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3267 make_C_tag (TRUE); /* an Objective C method */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3268 objdef = oinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3269 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3270 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3271 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3272 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3273 case fdefunkey:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3274 case foperator:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3275 case fstartlist:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3276 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3277 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3278 case vignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3279 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3280 case fdefunname:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3281 fvdef = fignore;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3282 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3283 case fvnameseen: /* a variable */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3284 if ((globals && cblev == 0 && (!fvextern || declarations))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3285 || (members && instruct))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3286 make_C_tag (FALSE);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3287 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3288 case flistseen: /* a function */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3289 if ((declarations && typdef == tnone && !instruct)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3290 || (members && typdef != tignore && instruct))
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 make_C_tag (TRUE); /* a function declaration */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3293 fvdef = fvnameseen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3294 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3295 else if (!declarations)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3296 fvdef = fvnone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3297 token.valid = FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3298 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3299 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3300 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3301 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3302 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3303 structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3304 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3305 case '[':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3306 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3307 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3308 if (structdef == stagseen)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3309 structdef = snone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3310 switch (typdef)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3311 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3312 case ttypeseen:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3313 case tend:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3314 typdef = tignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3315 make_C_tag (FALSE); /* a typedef */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3316 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3317 case tnone:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3318 case tinbody:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3319 switch (fvdef)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3320 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3321 case foperator:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3322 case finlist:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3323 case fignore:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3324 case vignore:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3325 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3326 case fvnameseen:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3327 if ((members && cblev == 1)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3328 || (globals && cblev == 0
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3329 && (!fvextern || declarations)))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3330 make_C_tag (FALSE); /* a variable */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3331 /* FALLTHRU */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3332 default:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3333 fvdef = fvnone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3334 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3335 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3336 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3337 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3338 case '(':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3339 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3340 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3341 if (objdef == otagseen && parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3342 objdef = oparenseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3343 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3344 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3345 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3346 if (typdef == ttypeseen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3347 && *lp != '*'
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3348 && !instruct)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3349 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3350 /* This handles constructs like:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3351 typedef void OperatorFun (int fun); */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3352 make_C_tag (FALSE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3353 typdef = tignore;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3354 fvdef = fignore;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3355 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3356 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3357 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3358 case foperator:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3359 fvdef = fstartlist;
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 case flistseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3362 fvdef = finlist;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3365 parlev++;
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 case ')':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3368 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3369 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3370 if (objdef == ocatseen && parlev == 1)
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 make_C_tag (TRUE); /* an Objective C category */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3373 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3374 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3375 if (--parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3376 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3377 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3378 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3379 case fstartlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3380 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3381 fvdef = flistseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3382 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3383 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3384 if (!instruct
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3385 && (typdef == tend
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3386 || typdef == ttypeseen))
428
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 typdef = tignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3389 make_C_tag (FALSE); /* a typedef */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3390 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3391 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3392 else if (parlev < 0) /* can happen due to ill-conceived #if's. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3393 parlev = 0;
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 case '{':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3396 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3397 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3398 if (typdef == ttypeseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3399 {
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
3400 /* Whenever typdef is set to tinbody (currently only
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
3401 here), typdefcblev should be set to cblev. */
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
3402 typdef = tinbody;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3403 typdefcblev = cblev;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3404 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3405 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3406 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3407 case flistseen:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3408 make_C_tag (TRUE); /* a function */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3409 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3410 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3411 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3412 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3413 case fvnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3414 switch (objdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3415 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3416 case otagseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3417 make_C_tag (TRUE); /* an Objective C class */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3418 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3419 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3420 case omethodtag:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3421 case omethodparm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3422 make_C_tag (TRUE); /* an Objective C method */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3423 objdef = oinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3424 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3425 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3426 /* Neutralize `extern "C" {' grot. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3427 if (cblev == 0 && structdef == snone && nestlev == 0
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3428 && typdef == tnone)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3429 cblev = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3430 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3431 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3432 switch (structdef)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3433 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3434 case skeyseen: /* unnamed struct */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3435 pushclass_above (cblev, NULL, 0);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3436 structdef = snone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3437 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3438 case stagseen: /* named struct or enum */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3439 case scolonseen: /* a class */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3440 pushclass_above (cblev, token.line+token.offset, token.length);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3441 structdef = snone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3442 make_C_tag (FALSE); /* a struct or enum */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3443 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3444 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3445 cblev++;
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 case '*':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3448 if (definedef != dnone)
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 if (fvdef == fstartlist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3451 fvdef = fvnone; /* avoid tagging `foo' in `foo (*bar()) ()' */
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 case '}':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3454 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3455 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3456 if (!noindentypedefs && lp == newlb.buffer + 1)
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 cblev = 0; /* reset curly brace level if first column */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3459 parlev = 0; /* also reset paren level, just in case... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3460 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3461 else if (cblev > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3462 cblev--;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3463 popclass_above (cblev);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3464 structdef = snone;
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
3465 /* Only if typdef == tinbody is typdefcblev significant. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3466 if (typdef == tinbody && cblev <= typdefcblev)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3467 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3468 assert (cblev == typdefcblev);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3469 typdef = tend;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3470 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3471 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3472 case '=':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3473 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3474 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3475 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3476 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3477 case foperator:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3478 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3479 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3480 case vignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3481 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3482 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3483 if ((members && cblev == 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3484 || (globals && cblev == 0 && (!fvextern || declarations)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3485 make_C_tag (FALSE); /* a variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3486 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3487 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3488 fvdef = vignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3489 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3490 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3491 case '<':
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3492 if (cplpl && structdef == stagseen)
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 structdef = sintemplate;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3495 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3496 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3497 goto resetfvdef;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3498 case '>':
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3499 if (structdef == sintemplate)
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 structdef = stagseen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3502 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3503 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3504 goto resetfvdef;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3505 case '+':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3506 case '-':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3507 if (objdef == oinbody && cblev == 0)
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 objdef = omethodsign;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3510 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3511 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3512 /* FALLTHRU */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3513 resetfvdef:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3514 case '#': case '~': case '&': case '%': case '/': case '|':
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3515 case '^': case '!': case '.': case '?': case ']':
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3516 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3517 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3518 /* These surely cannot follow a function tag in C. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3519 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3520 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3521 case foperator:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3522 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3523 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3524 case vignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3525 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3526 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3527 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3528 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3529 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3530 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3531 if (objdef == otagseen)
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 make_C_tag (TRUE); /* an Objective C class */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3534 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3535 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3536 /* If a macro spans multiple lines don't reset its state. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3537 if (quotednl)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3538 CNL_SAVE_DEFINEDEF ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3539 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3540 CNL ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3541 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3542 } /* switch (c) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3543
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3544 } /* while not eof */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3545
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3546 free (token_name.buffer);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3547 free (lbs[0].lb.buffer);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3548 free (lbs[1].lb.buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3549 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3550
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3551 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3552 * 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
3553 * of a global flag.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3554 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3555 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3556 default_C_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3557 FILE *inf;
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 C_entries (cplusplus ? C_PLPL : C_AUTO, inf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3560 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3561
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3562 /* Always do plain C. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3563 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3564 plain_C_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3565 FILE *inf;
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 C_entries (0, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3568 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3569
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3570 /* Always do C++. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3571 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3572 Cplusplus_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3573 FILE *inf;
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 C_entries (C_PLPL, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3576 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3577
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3578 /* Always do Java. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3579 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3580 Cjava_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3581 FILE *inf;
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 C_entries (C_JAVA, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3584 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3585
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3586 /* Always do C*. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3587 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3588 Cstar_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3589 FILE *inf;
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 C_entries (C_STAR, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3592 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3593
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3594 /* Always do Yacc. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3595 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3596 Yacc_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3597 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3598 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3599 C_entries (YACC, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3600 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3601
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3602
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
3603 /* Useful macros. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3604 #define LOOP_ON_INPUT_LINES(file_pointer, line_buffer, char_pointer) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3605 for (lineno = charno = 0; /* loop initialization */ \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3606 !feof (file_pointer) /* loop test */ \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3607 && (lineno++, /* instructions at start of loop */ \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3608 linecharno = charno, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3609 charno += readline (&line_buffer, file_pointer), \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3610 char_pointer = lb.buffer, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3611 TRUE); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3612 )
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
3613 #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
3614 (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
3615 && 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
3616 && ((cp) = skip_spaces((cp)+sizeof(keyword)-1))) /* skip blanks */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3617
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3618 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3619 * 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
3620 * matching on files that have no language defined.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3621 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3622 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3623 just_read_file (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3624 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3625 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3626 register char *dummy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3627
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3628 LOOP_ON_INPUT_LINES (inf, lb, dummy)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3629 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3630 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3631
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3632
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3633 /* Fortran parsing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3634
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
3635 static bool tail __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
3636 static void takeprec __P((void));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
3637 static void getit __P((FILE *));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3638
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3639 static bool
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3640 tail (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3641 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3642 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3643 register int len = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3644
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3645 while (*cp != '\0' && lowcase (*cp) == lowcase (dbp[len]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3646 cp++, len++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3647 if (*cp == '\0' && !intoken (dbp[len]))
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 dbp += len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3650 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3651 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3652 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3653 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3654
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3655 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3656 takeprec ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3657 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3658 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3659 if (*dbp != '*')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3660 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3661 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3662 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3663 if (strneq (dbp, "(*)", 3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3664 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3665 dbp += 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3666 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3667 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3668 if (!ISDIGIT (*dbp))
428
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 --dbp; /* force failure */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3671 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3672 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3673 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3674 dbp++;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3675 while (ISDIGIT (*dbp));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3676 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3677
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3678 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3679 getit (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3680 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3681 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3682 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3683
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3684 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3685 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3686 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3687 lineno++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3688 linecharno = charno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3689 charno += readline (&lb, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3690 dbp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3691 if (dbp[5] != '&')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3692 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3693 dbp += 6;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3694 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3695 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3696 if (!ISALPHA (*dbp) && *dbp != '_' && *dbp != '$')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3697 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3698 for (cp = dbp + 1; *cp != '\0' && intoken (*cp); cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3699 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3700 pfnote (savenstr (dbp, cp-dbp), TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3701 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3702 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3703
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3704
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3705 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3706 Fortran_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3707 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3708 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3709 LOOP_ON_INPUT_LINES (inf, lb, dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3710 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3711 if (*dbp == '%')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3712 dbp++; /* Ratfor escape to fortran */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3713 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3714 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3715 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3716 switch (lowcase (*dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3717 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3718 case 'i':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3719 if (tail ("integer"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3720 takeprec ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3721 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3722 case 'r':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3723 if (tail ("real"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3724 takeprec ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3725 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3726 case 'l':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3727 if (tail ("logical"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3728 takeprec ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3729 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3730 case 'c':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3731 if (tail ("complex") || tail ("character"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3732 takeprec ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3733 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3734 case 'd':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3735 if (tail ("double"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3736 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3737 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3738 if (*dbp == '\0')
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 if (tail ("precision"))
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 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3743 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3744 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3745 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3746 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3747 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3748 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3749 switch (lowcase (*dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3750 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3751 case 'f':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3752 if (tail ("function"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3753 getit (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3754 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3755 case 's':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3756 if (tail ("subroutine"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3757 getit (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3758 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3759 case 'e':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3760 if (tail ("entry"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3761 getit (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3762 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3763 case 'b':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3764 if (tail ("blockdata") || tail ("block data"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3765 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3766 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3767 if (*dbp == '\0') /* assume un-named */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3768 pfnote (savestr ("blockdata"), TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3769 lb.buffer, dbp - lb.buffer, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3770 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3771 getit (inf); /* look for name */
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 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3774 }
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 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3777
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3778
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3779 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3780 * Ada parsing
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3781 * Philippe Waroquiers <philippe.waroquiers@eurocontrol.be> (1998)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3782 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3783
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
3784 static void adagetit __P((FILE *, char *));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3785
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3786 /* Once we are positioned after an "interesting" keyword, let's get
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3787 the real tag value necessary. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3788 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3789 adagetit (inf, name_qualifier)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3790 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3791 char *name_qualifier;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3792 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3793 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3794 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3795 char c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3796
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3797 while (!feof (inf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3798 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3799 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3800 if (*dbp == '\0'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3801 || (dbp[0] == '-' && dbp[1] == '-'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3802 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3803 lineno++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3804 linecharno = charno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3805 charno += readline (&lb, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3806 dbp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3807 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3808 switch (*dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3809 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3810 case 'b':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3811 case 'B':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3812 if (tail ("body"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3813 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3814 /* Skipping body of procedure body or package body or ....
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3815 resetting qualifier to body instead of spec. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3816 name_qualifier = "/b";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3817 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3818 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3819 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3820 case 't':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3821 case 'T':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3822 /* Skipping type of task type or protected type ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3823 if (tail ("type"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3824 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3825 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3826 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3827 if (*dbp == '"')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3828 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3829 dbp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3830 for (cp = dbp; *cp != '\0' && *cp != '"'; cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3831 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3832 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3833 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3834 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3835 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3836 for (cp = dbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3837 (*cp != '\0'
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3838 && (ISALPHA (*cp) || ISDIGIT (*cp) || *cp == '_' || *cp == '.'));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3839 cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3840 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3841 if (cp == dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3842 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3843 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3844 c = *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3845 *cp = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3846 name = concat (dbp, name_qualifier, "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3847 *cp = c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3848 pfnote (name, TRUE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3849 if (c == '"')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3850 dbp = cp + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3851 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3852 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3853 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3854
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3855 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3856 Ada_funcs (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3857 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3858 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3859 bool inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3860
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3861 LOOP_ON_INPUT_LINES (inf, lb, dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3862 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3863 while (*dbp != '\0')
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 /* Skip a string i.e. "abcd". */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3866 if (inquote || (*dbp == '"'))
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 dbp = etags_strchr ((inquote) ? dbp : dbp+1, '"');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3869 if (dbp != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3870 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3871 inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3872 dbp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3873 continue; /* advance char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3874 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3875 else
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 inquote = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3878 break; /* advance line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3879 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3880 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3881
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3882 /* Skip comments. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3883 if (dbp[0] == '-' && dbp[1] == '-')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3884 break; /* advance line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3885
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3886 /* Skip character enclosed in single quote i.e. 'a'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3887 and skip single quote starting an attribute i.e. 'Image. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3888 if (*dbp == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3889 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3890 dbp++ ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3891 if (*dbp != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3892 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3893 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3894 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3895
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3896 /* Search for beginning of a token. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3897 if (!begtoken (*dbp))
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 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3900 continue; /* advance char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3901 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3902
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3903 /* We are at the beginning of a token. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3904 switch (*dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3905 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3906 case 'f':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3907 case 'F':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3908 if (!packages_only && tail ("function"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3909 adagetit (inf, "/f");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3910 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3911 break; /* from switch */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3912 continue; /* advance char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3913 case 'p':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3914 case 'P':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3915 if (!packages_only && tail ("procedure"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3916 adagetit (inf, "/p");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3917 else if (tail ("package"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3918 adagetit (inf, "/s");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3919 else if (tail ("protected")) /* protected type */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3920 adagetit (inf, "/t");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3921 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3922 break; /* from switch */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3923 continue; /* advance char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3924 case 't':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3925 case 'T':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3926 if (!packages_only && tail ("task"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3927 adagetit (inf, "/k");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3928 else if (typedefs && !packages_only && tail ("type"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3929 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3930 adagetit (inf, "/t");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3931 while (*dbp != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3932 dbp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3933 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3934 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3935 break; /* from switch */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3936 continue; /* advance char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3937 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3938
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3939 /* Look for the end of the token. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3940 while (!endtoken (*dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3941 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3942
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3943 } /* advance char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3944 } /* advance line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3945 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3946
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3947
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3948 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3949 * Bob Weiner, Motorola Inc., 4/3/94
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3950 * Unix and microcontroller assembly tag handling
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3951 * look for '^[a-zA-Z_.$][a-zA_Z0-9_.$]*[: ^I^J]'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3952 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3953 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3954 Asm_labels (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3955 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3956 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3957 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3958
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3959 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3960 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3961 /* If first char is alphabetic or one of [_.$], test for colon
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3962 following identifier. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3963 if (ISALPHA (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3964 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3965 /* Read past label. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3966 cp++;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3967 while (ISALNUM (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3968 cp++;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3969 if (*cp == ':' || iswhite (*cp))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3970 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3971 /* 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
3972 pfnote (savenstr(lb.buffer, cp-lb.buffer), TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3973 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3974 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3975 }
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
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3979
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3980 /*
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3981 * Perl support
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3982 * Perl sub names: look for /^sub[ \t\n]+[^ \t\n{]+/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3983 * Perl variable names: /^(my|local).../
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3984 * Bart Robinson <lomew@cs.utah.edu> (1995)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3985 * Michael Ernst <mernst@alum.mit.edu> (1997)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3986 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3987 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3988 Perl_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3989 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3990 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3991 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3992
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3993 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3994 {
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
3995 if (LOOKING_AT (cp, "sub"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3996 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3997 if (*cp != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3998 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3999 char *sp = cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4000 while (*cp != '\0'
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4001 && !iswhite (*cp) && *cp != '{' && *cp != '(')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4002 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4003 pfnote (savenstr (sp, cp-sp), TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4004 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4005 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4006 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4007 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
4008 && ((strneq (cp, "my", 2) && (cp+=2))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4009 || (strneq (cp, "local", 5) && (cp+=5)))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4010 && (*cp == '(' || iswhite (*cp)))
428
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 /* After "my" or "local", but before any following paren or space. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4013 char *varname = NULL;
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 cp = skip_spaces (cp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4016 if (*cp == '$' || *cp == '@' || *cp == '%')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4017 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4018 char* varstart = ++cp;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4019 while (ISALNUM (*cp) || *cp == '_')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4020 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4021 varname = savenstr (varstart, cp-varstart);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4022 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4023 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4024 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4025 /* Should be examining a variable list at this point;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4026 could insist on seeing an open parenthesis. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4027 while (*cp != '\0' && *cp != ';' && *cp != '=' && *cp != ')')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4028 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4029 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4030
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4031 /* Perhaps I should back cp up one character, so the TAGS table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4032 doesn't mention (and so depend upon) the following char. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4033 pfnote ((CTAGS) ? savenstr (lb.buffer, cp-lb.buffer) : varname,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4034 FALSE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4035 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4036 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4037 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4038
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4039
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4040 /*
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4041 * Python support
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4042 * 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
4043 * Eric S. Raymond <esr@thyrsus.com> (1997)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4044 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4045 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4046 Python_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4047 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4048 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4049 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4050
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4051 LOOP_ON_INPUT_LINES (inf, lb, cp)
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4052 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
4053 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4054 while (*cp != '\0' && !iswhite (*cp) && *cp != '(' && *cp != ':')
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4055 cp++;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4056 pfnote (NULL, TRUE,
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4057 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
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
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4061
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4062 /*
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4063 * PHP support
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4064 * Look for:
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4065 * - /^[ \t]*function[ \t\n]+[^ \t\n(]+/
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4066 * - /^[ \t]*class[ \t\n]+[^ \t\n]+/
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4067 * - /^[ \t]*define\(\"[^\"]+/
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4068 * Only with --members:
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4069 * - /^[ \t]*var[ \t\n]+\$[^ \t\n=;]/
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4070 * originally by Diez B. Roggisch 2001-06-06
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4071 */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4072 static void
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4073 PHP_functions (inf)
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4074 FILE *inf;
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 register char *cp;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4077 bool search_identifier = FALSE;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4078
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4079 LOOP_ON_INPUT_LINES (inf, lb, cp)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4080 {
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4081 cp = skip_spaces (cp);
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4082 if (search_identifier
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4083 && *cp != '\0')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4084 {
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4085 while (*cp != '\0' && !iswhite (*cp) && *cp != '(')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4086 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4087 pfnote (NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4088 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
4089 search_identifier = FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4090 }
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4091 else if (LOOKING_AT (cp, "function"))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4092 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4093 if(*cp == '&')
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4094 cp = skip_spaces (cp+1);
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4095 if(*cp != '\0')
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4096 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4097 while (*cp != '\0' && !iswhite (*cp) && *cp != '(')
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4098 cp++;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4099 pfnote (NULL, TRUE,
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4100 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
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
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4103 search_identifier = TRUE;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4104 }
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4105 else if (LOOKING_AT (cp, "class"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4106 {
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4107 if (*cp != '\0')
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4108 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4109 while (*cp != '\0' && !iswhite (*cp))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4110 cp++;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4111 pfnote (NULL, FALSE,
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4112 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
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
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4115 search_identifier = TRUE;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4116 }
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4117 else if (strneq (cp, "define", 6)
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4118 && (cp = skip_spaces (cp+6))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4119 && *cp++ == '('
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4120 && (*cp == '"' || *cp == '\''))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4121 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4122 char quote = *cp++;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4123 while (*cp != quote && *cp != '\0')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4124 cp++;
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4125 pfnote (NULL, FALSE,
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4126 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4127 }
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4128 else if (members
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4129 && LOOKING_AT (cp, "var")
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 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4132 while (*cp != '=' && *cp != ';' && *cp != '\0' && !iswhite(*cp))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4133 cp++;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4134 pfnote (NULL, FALSE,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4135 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4136 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4137 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4138 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4139
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4140
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4141 /* Idea by Corny de Souza
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4142 * Cobol tag functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4143 * We could look for anything that could be a paragraph name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4144 * 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
4145 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4146 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4147 Cobol_paragraphs (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4148 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4149 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4150 register char *bp, *ep;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4152 LOOP_ON_INPUT_LINES (inf, lb, bp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4153 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4154 if (lb.len < 9)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4155 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4156 bp += 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4157
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4158 /* If eoln, compiler option or comment ignore whole line. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4159 if (bp[-1] != ' ' || !ISALNUM (bp[0]))
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
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4162 for (ep = bp; ISALNUM (*ep) || *ep == '-'; ep++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4163 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4164 if (*ep++ == '.')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4165 pfnote (savenstr (bp, ep-bp), TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4166 lb.buffer, ep - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4167 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4168 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4169
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4170
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 * Makefile support
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4173 * Idea by Assar Westerlund <assar@sics.se> (2001)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4174 */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4175 static void
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4176 Makefile_targets (inf)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4177 FILE *inf;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4178 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4179 register char *bp;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4180
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4181 LOOP_ON_INPUT_LINES (inf, lb, bp)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4182 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4183 if (*bp == '\t' || *bp == '#')
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4184 continue;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4185 while (*bp != '\0' && *bp != '=' && *bp != ':')
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4186 bp++;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4187 if (*bp == ':')
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4188 pfnote (savenstr (lb.buffer, bp - lb.buffer), TRUE,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4189 lb.buffer, bp - lb.buffer + 1, lineno, linecharno);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4190 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4191 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4192
428
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 /* Added by Mosur Mohan, 4/22/88 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4195 /* Pascal parsing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4196
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4197 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4198 * Locates tags for procedures & functions. Doesn't do any type- or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4199 * var-definitions. It does look for the keyword "extern" or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4200 * "forward" immediately following the procedure statement; if found,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4201 * the tag is skipped.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4202 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4203 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4204 Pascal_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4205 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4206 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4207 linebuffer tline; /* mostly copied from C_entries */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4208 long save_lcno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4209 int save_lineno, save_len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4210 char c, *cp, *namebuf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4211
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4212 bool /* each of these flags is TRUE iff: */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4213 incomment, /* point is inside a comment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4214 inquote, /* point is inside '..' string */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4215 get_tagname, /* point is after PROCEDURE/FUNCTION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4216 keyword, so next item = potential tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4217 found_tag, /* point is after a potential tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4218 inparms, /* point is within parameter-list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4219 verify_tag; /* point has passed the parm-list, so the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4220 next token will determine whether this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4221 is a FORWARD/EXTERN to be ignored, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4222 whether it is a real tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4223
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4224 save_lcno = save_lineno = save_len = 0; /* keep compiler quiet */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4225 namebuf = NULL; /* keep compiler quiet */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4226 lineno = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4227 charno = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4228 dbp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4229 *dbp = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4230 initbuffer (&tline);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4231
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4232 incomment = inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4233 found_tag = FALSE; /* have a proc name; check if extern */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4234 get_tagname = FALSE; /* have found "procedure" keyword */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4235 inparms = FALSE; /* found '(' after "proc" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4236 verify_tag = FALSE; /* check if "extern" is ahead */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4239 while (!feof (inf)) /* long main loop to get next char */
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 c = *dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4242 if (c == '\0') /* if end of line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4243 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4244 lineno++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4245 linecharno = charno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4246 charno += readline (&lb, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4247 dbp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4248 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4249 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4250 if (!((found_tag && verify_tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4251 || get_tagname))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4252 c = *dbp++; /* only if don't need *dbp pointing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4253 to the beginning of the name of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4254 the procedure or function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4255 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4256 if (incomment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4257 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4258 if (c == '}') /* within { } comments */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4259 incomment = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4260 else if (c == '*' && *dbp == ')') /* within (* *) comments */
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 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4263 incomment = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4264 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4265 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4266 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4267 else if (inquote)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4268 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4269 if (c == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4270 inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4271 continue;
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4274 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4275 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4276 case '\'':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4277 inquote = TRUE; /* found first quote */
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 '{': /* found open { comment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4280 incomment = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4281 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4282 case '(':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4283 if (*dbp == '*') /* found open (* comment */
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 incomment = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4286 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4287 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4288 else if (found_tag) /* found '(' after tag, i.e., parm-list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4289 inparms = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4290 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4291 case ')': /* end of parms list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4292 if (inparms)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4293 inparms = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4294 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4295 case ';':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4296 if (found_tag && !inparms) /* end of proc or fn stmt */
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 verify_tag = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4299 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4300 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4301 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4302 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4303 if (found_tag && verify_tag && (*dbp != ' '))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4304 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4305 /* check if this is an "extern" declaration */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4306 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4307 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4308 if (lowcase (*dbp == 'e'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4309 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4310 if (tail ("extern")) /* superfluous, really! */
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 found_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4313 verify_tag = FALSE;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4316 else if (lowcase (*dbp) == 'f')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4317 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4318 if (tail ("forward")) /* check for forward reference */
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 found_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4321 verify_tag = FALSE;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4324 if (found_tag && verify_tag) /* not external proc, so make tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4325 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4326 found_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4327 verify_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4328 pfnote (namebuf, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4329 tline.buffer, save_len, save_lineno, save_lcno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4330 continue;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4333 if (get_tagname) /* grab name of proc or fn */
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 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4336 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4337
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4338 /* save all values for later tagging */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4339 linebuffer_setlen (&tline, lb.len);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4340 strcpy (tline.buffer, lb.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4341 save_lineno = lineno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4342 save_lcno = linecharno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4343
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4344 /* grab block name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4345 for (cp = dbp + 1; *cp != '\0' && !endtoken (*cp); cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4346 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4347 namebuf = savenstr (dbp, cp-dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4348 dbp = cp; /* set dbp to e-o-token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4349 save_len = dbp - lb.buffer + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4350 get_tagname = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4351 found_tag = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4352 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4353
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4354 /* and proceed to check for "extern" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4355 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4356 else if (!incomment && !inquote && !found_tag)
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 /* check for proc/fn keywords */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4359 switch (lowcase (c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4360 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4361 case 'p':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4362 if (tail ("rocedure")) /* c = 'p', dbp has advanced */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4363 get_tagname = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4364 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4365 case 'f':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4366 if (tail ("unction"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4367 get_tagname = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4368 continue;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4371 } /* while not eof */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4372
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4373 free (tline.buffer);
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
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4376
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4377 /*
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4378 * Lisp tag functions
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4379 * look for (def or (DEF, quote or QUOTE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4380 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4381
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4382 static int L_isdef __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4383 static int L_isquote __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4384 static void L_getit __P((void));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4385
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4386 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4387 L_isdef (strp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4388 register char *strp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4389 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4390 return ((strp[1] == 'd' || strp[1] == 'D')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4391 && (strp[2] == 'e' || strp[2] == 'E')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4392 && (strp[3] == 'f' || strp[3] == 'F'));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4393 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4394
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4395 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4396 L_isquote (strp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4397 register char *strp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4398 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4399 return ((*++strp == 'q' || *strp == 'Q')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4400 && (*++strp == 'u' || *strp == 'U')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4401 && (*++strp == 'o' || *strp == 'O')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4402 && (*++strp == 't' || *strp == 'T')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4403 && (*++strp == 'e' || *strp == 'E')
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4404 && iswhite (*++strp));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4405 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4406
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4407 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4408 L_getit ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4409 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4410 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4411
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4412 if (*dbp == '\'') /* Skip prefix quote */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4413 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4414 else if (*dbp == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4415 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4416 if (L_isquote (dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4417 dbp += 7; /* Skip "(quote " */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4418 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4419 dbp += 1; /* Skip "(" before name in (defstruct (foo)) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4420 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4421 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4422
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4423 for (cp = dbp /*+1*/;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4424 *cp != '\0' && *cp != '(' && !iswhite(*cp) && *cp != ')';
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4425 cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4426 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4427 if (cp == dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4428 return;
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 pfnote (savenstr (dbp, cp-dbp), TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4431 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4432 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4433
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4434 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4435 Lisp_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4436 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4437 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4438 LOOP_ON_INPUT_LINES (inf, lb, dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4439 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4440 if (dbp[0] == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4441 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4442 if (L_isdef (dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4443 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4444 dbp = skip_non_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4445 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4446 L_getit ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4447 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4448 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4449 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4450 /* Check for (foo::defmumble name-defined ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4451 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4452 dbp++;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4453 while (*dbp != '\0' && !iswhite (*dbp)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4454 && *dbp != ':' && *dbp != '(' && *dbp != ')');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4455 if (*dbp == ':')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4456 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4457 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4458 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4459 while (*dbp == ':');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4460
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4461 if (L_isdef (dbp - 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4462 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4463 dbp = skip_non_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4464 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4465 L_getit ();
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4469 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4470 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4471 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4472
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4473
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4474 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4475 * Postscript tag functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4476 * Just look for lines where the first character is '/'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4477 * Also look at "defineps" for PSWrap
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4478 * Richard Mlynarik <mly@adoc.xerox.com> (1997)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4479 * 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
4480 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4481 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4482 Postscript_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4483 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4484 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4485 register char *bp, *ep;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4486
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4487 LOOP_ON_INPUT_LINES (inf, lb, bp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4488 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4489 if (bp[0] == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4490 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4491 for (ep = bp+1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4492 *ep != '\0' && *ep != ' ' && *ep != '{';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4493 ep++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4494 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4495 pfnote (savenstr (bp, ep-bp), TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4496 lb.buffer, ep - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4497 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4498 else if (strneq (bp, "defineps", 8))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4499 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4500 bp = skip_non_spaces (bp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4501 bp = skip_spaces (bp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4502 get_tag (bp);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4507
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4508 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4509 * Scheme tag functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4510 * look for (def... xyzzy
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4511 * look for (def... (xyzzy
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4512 * look for (def ... ((...(xyzzy ....
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4513 * look for (set! xyzzy
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4514 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4515
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4516 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4517 Scheme_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4518 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4519 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4520 register char *bp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4521
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4522 LOOP_ON_INPUT_LINES (inf, lb, bp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4523 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4524 if (bp[0] == '('
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4525 && (bp[1] == 'D' || bp[1] == 'd')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4526 && (bp[2] == 'E' || bp[2] == 'e')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4527 && (bp[3] == 'F' || bp[3] == 'f'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4528 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4529 bp = skip_non_spaces (bp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4530 /* Skip over open parens and white space */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4531 while (iswhite (*bp) || *bp == '(')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4532 bp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4533 get_tag (bp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4534 }
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4535 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
4536 get_tag (bp);
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 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4539
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4540
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4541 /* Find tags in TeX and LaTeX input files. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4542
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4543 /* TEX_toktab is a table of TeX control sequences that define tags.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4544 Each TEX_tabent records one such control sequence.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4545 CONVERT THIS TO USE THE Stab TYPE!! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4546 struct TEX_tabent
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 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4549 int len;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4552 struct TEX_tabent *TEX_toktab = NULL; /* Table with tag tokens */
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 /* Default set of control sequences to put into TEX_toktab.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4555 The value of environment var TEXTAGS is prepended to this. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4556
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4557 char *TEX_defenv = "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4558 :chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4559 :part:appendix:entry:index";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4560
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4561 static void TEX_mode __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4562 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
4563 static int TEX_Token __P((char *));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4564
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4565 char TEX_esc = '\\';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4566 char TEX_opgrp = '{';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4567 char TEX_clgrp = '}';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4568
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4569 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4570 * TeX/LaTeX scanning loop.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4571 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4572 static void
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4573 TeX_commands (inf)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4574 FILE *inf;
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 char *cp, *lasthit;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4577 register int i;
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 /* Select either \ or ! as escape character. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4580 TEX_mode (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4581
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4582 /* Initialize token table once from environment. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4583 if (!TEX_toktab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4584 TEX_toktab = TEX_decode_env ("TEXTAGS", TEX_defenv);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4585
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4586 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4587 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4588 lasthit = cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4589 /* Look at each esc in line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4590 while ((cp = etags_strchr (cp, TEX_esc)) != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4591 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4592 if (*++cp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4593 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4594 linecharno += cp - lasthit;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4595 lasthit = cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4596 i = TEX_Token (lasthit);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4597 if (i >= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4598 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4599 /* We seem to include the TeX command in the tag name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4600 register char *p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4601 for (p = lasthit + TEX_toktab[i].len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4602 *p != '\0' && *p != TEX_clgrp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4603 p++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4604 continue; */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4605 pfnote (/*savenstr (lasthit, p-lasthit)*/ (char *)NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4606 lb.buffer, lb.len, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4607 break; /* We only tag a line once */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4608 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4609 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4610 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4611 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4612
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4613 #define TEX_LESC '\\'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4614 #define TEX_SESC '!'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4615 #define TEX_cmt '%'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4616
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4617 /* Figure out whether TeX's escapechar is '\\' or '!' and set grouping
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4618 chars accordingly. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4619 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4620 TEX_mode (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4621 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4622 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4623 int c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4624
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4625 while ((c = getc (inf)) != EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4626 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4627 /* Skip to next line if we hit the TeX comment char. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4628 if (c == TEX_cmt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4629 while (c != '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4630 c = getc (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4631 else if (c == TEX_LESC || c == TEX_SESC )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4632 break;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4635 if (c == TEX_LESC)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4636 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4637 TEX_esc = TEX_LESC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4638 TEX_opgrp = '{';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4639 TEX_clgrp = '}';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4640 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4641 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4642 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4643 TEX_esc = TEX_SESC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4644 TEX_opgrp = '<';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4645 TEX_clgrp = '>';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4646 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4647 /* 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
4648 No attempt is made to correct the situation. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4649 rewind (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4650 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4651
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4652 /* Read environment and prepend it to the default string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4653 Build token table. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4654 static struct TEX_tabent *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4655 TEX_decode_env (evarname, defenv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4656 char *evarname;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4657 char *defenv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4658 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4659 register char *env, *p;
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 struct TEX_tabent *tab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4662 int size, i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4663
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4664 /* Append default string to environment. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4665 env = getenv (evarname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4666 if (!env)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4667 env = defenv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4668 else
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 char *oldenv = env;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4671 env = concat (oldenv, defenv, "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4672 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4673
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4674 /* Allocate a token table */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4675 for (size = 1, p = env; p;)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4676 if ((p = etags_strchr (p, ':')) && *++p != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4677 size++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4678 /* Add 1 to leave room for null terminator. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4679 tab = xnew (size + 1, struct TEX_tabent);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4680
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4681 /* Unpack environment string into token table. Be careful about */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4682 /* zero-length strings (leading ':', "::" and trailing ':') */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4683 for (i = 0; *env;)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4684 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4685 p = etags_strchr (env, ':');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4686 if (!p) /* End of environment string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4687 p = env + strlen (env);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4688 if (p - env > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4689 { /* Only non-zero strings. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4690 tab[i].name = savenstr (env, p - env);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4691 tab[i].len = strlen (tab[i].name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4692 i++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4693 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4694 if (*p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4695 env = p + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4696 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4697 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4698 tab[i].name = NULL; /* Mark end of table. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4699 tab[i].len = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4700 break;
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 return tab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4704 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4705
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4706 /* 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
4707 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
4708 Otherwise return -1.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4709 Keep the capital `T' in `token' for dumb truncating compilers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4710 (this distinguishes it from `TEX_toktab' */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4711 static int
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4712 TEX_Token (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4713 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4714 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4715 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4716
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4717 for (i = 0; TEX_toktab[i].len > 0; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4718 if (strneq (TEX_toktab[i].name, cp, TEX_toktab[i].len))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4719 return i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4720 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4721 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4722
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4723
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4724 /* Texinfo support. Dave Love, Mar. 2000. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4725 static void
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4726 Texinfo_nodes (inf)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4727 FILE * inf;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4728 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4729 char *cp, *start;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4730 LOOP_ON_INPUT_LINES (inf, lb, cp)
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4731 if (LOOKING_AT (cp, "@node"))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4732 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4733 start = cp;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4734 while (*cp != '\0' && *cp != ',')
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4735 cp++;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4736 pfnote (savenstr (start, cp - start), TRUE,
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4737 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4738 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4739 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4740
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4741
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4742 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4743 * Prolog support (rewritten) by Anders Lindgren, Mar. 96
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 * 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
4746 * Only the first clause of a predicate or rule is added.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4747 */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4748 static int prolog_pr __P((char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4749 static void prolog_skip_comment __P((linebuffer *, FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4750 static int prolog_atom __P((char *, int));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4751
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4752 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4753 Prolog_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4754 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4755 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4756 char *cp, *last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4757 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4758 int allocated;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4759
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4760 allocated = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4761 len = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4762 last = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4763
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4764 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4765 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4766 if (cp[0] == '\0') /* Empty line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4767 continue;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4768 else if (iswhite (cp[0])) /* Not a predicate */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4769 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4770 else if (cp[0] == '/' && cp[1] == '*') /* comment. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4771 prolog_skip_comment (&lb, inf);
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4772 else if ((len = prolog_pr (cp, last)) > 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4773 {
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4774 /* 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
4775 only generate a tag for the first clause. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4776 if (last == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4777 last = xnew(len + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4778 else if (len + 1 > allocated)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4779 xrnew (last, len + 1, char);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4780 allocated = len + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4781 strncpy (last, cp, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4782 last[len] = '\0';
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4785 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4786
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4787
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4788 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4789 prolog_skip_comment (plb, inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4790 linebuffer *plb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4791 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4792 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4793 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4794
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4795 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4796 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4797 for (cp = plb->buffer; *cp != '\0'; cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4798 if (cp[0] == '*' && cp[1] == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4799 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4800 lineno++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4801 linecharno += readline (plb, inf);
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 while (!feof(inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4804 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4805
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4806 /*
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4807 * A predicate or rule definition is added if it matches:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4808 * <beginning of line><Prolog Atom><whitespace>(
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4809 * or <beginning of line><Prolog Atom><whitespace>:-
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4810 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4811 * 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
4812 * name of the previous clause header.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4813 *
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4814 * 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
4815 * header was found.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4816 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4817 static int
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4818 prolog_pr (s, last)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4819 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4820 char *last; /* Name of last clause. */
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 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4823 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4824
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4825 pos = prolog_atom (s, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4826 if (pos < 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4827 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4828
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4829 len = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4830 pos = skip_spaces (s + pos) - s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4831
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4832 if ((s[pos] == '.'
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4833 || (s[pos] == '(' && (pos += 1))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4834 || (s[pos] == ':' && s[pos + 1] == '-' && (pos += 2)))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4835 && (last == NULL /* save only the first clause */
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 715
diff changeset
4836 || len != (int) strlen (last)
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4837 || !strneq (s, last, len)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4838 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4839 pfnote (savenstr (s, len), TRUE, s, pos, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4840 return len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4841 }
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4842 else
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4843 return 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4844 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4845
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 * Consume a Prolog atom.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4848 * 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
4849 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4850 * A prolog atom, in this context, could be one of:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4851 * - An alphanumeric sequence, starting with a lower case letter.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4852 * - A quoted arbitrary string. Single quotes can escape themselves.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4853 * Backslash quotes everything.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4854 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4855 static int
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4856 prolog_atom (s, pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4857 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4858 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4859 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4860 int origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4861
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4862 origpos = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4863
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4864 if (ISLOWER(s[pos]) || (s[pos] == '_'))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4865 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4866 /* The atom is unquoted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4867 pos++;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4868 while (ISALNUM(s[pos]) || (s[pos] == '_'))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4869 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4870 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4871 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4872 return pos - origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4873 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4874 else if (s[pos] == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4875 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4876 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4877
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4878 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4879 {
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 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4882 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4883 if (s[pos] != '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4884 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4885 pos++; /* A double quote */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4886 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4887 else if (s[pos] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4888 /* Multiline quoted atoms are ignored. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4889 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4890 else if (s[pos] == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4891 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4892 if (s[pos+1] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4893 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4894 pos += 2;
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4897 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4898 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4899 return pos - origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4900 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4901 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4902 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4903 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4904
428
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4907 * Support for Erlang -- Anders Lindgren, Feb 1996.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4908 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4909 * Generates tags for functions, defines, and records.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4910 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4911 * Assumes that Erlang functions start at column 0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4912 */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4913 static int erlang_func __P((char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4914 static void erlang_attribute __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4915 static int erlang_atom __P((char *, int));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4916
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4917 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4918 Erlang_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4919 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4920 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4921 char *cp, *last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4922 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4923 int allocated;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4924
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4925 allocated = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4926 len = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4927 last = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4928
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4929 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4930 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4931 if (cp[0] == '\0') /* Empty line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4932 continue;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4933 else if (iswhite (cp[0])) /* Not function nor attribute */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4934 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4935 else if (cp[0] == '%') /* comment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4936 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4937 else if (cp[0] == '"') /* Sometimes, strings start in column one */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4938 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4939 else if (cp[0] == '-') /* attribute, e.g. "-define" */
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 erlang_attribute (cp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4942 last = NULL;
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 else if ((len = erlang_func (cp, last)) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4945 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4946 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4947 * Function. Store the function name so that we only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4948 * generates a tag for the first clause.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4949 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4950 if (last == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4951 last = xnew (len + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4952 else if (len + 1 > allocated)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4953 xrnew (last, len + 1, char);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4954 allocated = len + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4955 strncpy (last, cp, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4956 last[len] = '\0';
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4961
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4962 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4963 * A function definition is added if it matches:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4964 * <beginning of line><Erlang Atom><whitespace>(
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 * 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
4967 * name of the previous clause header.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4968 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4969 * 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
4970 * was found.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4971 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4972 static int
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4973 erlang_func (s, last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4974 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4975 char *last; /* Name of last clause. */
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 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4978 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4979
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4980 pos = erlang_atom (s, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4981 if (pos < 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4982 return 0;
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 len = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4985 pos = skip_spaces (s + pos) - s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4986
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4987 /* Save only the first clause. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4988 if (s[pos++] == '('
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4989 && (last == NULL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4990 || len != (int)strlen (last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4991 || !strneq (s, last, 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 pfnote (savenstr (s, len), TRUE, s, pos, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4994 return len;
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 return 0;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5000
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5001 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5002 * Handle attributes. Currently, tags are generated for defines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5003 * and records.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5004 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5005 * They are on the form:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5006 * -define(foo, bar).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5007 * -define(Foo(M, N), M+N).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5008 * -record(graph, {vtab = notable, cyclic = true}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5009 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5010 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5011 erlang_attribute (s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5012 char *s;
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 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5015 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5016
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5017 if (strneq (s, "-define", 7) || strneq (s, "-record", 7))
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 + 7) - s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5020 if (s[pos++] == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5021 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5022 pos = skip_spaces (s + pos) - s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5023 len = erlang_atom (s, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5024 if (len != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5025 pfnote (savenstr (& s[pos], len), TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5026 s, pos + len, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5027 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5028 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5029 return;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5032
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5033 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5034 * Consume an Erlang atom (or variable).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5035 * 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
5036 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5037 static int
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5038 erlang_atom (s, pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5039 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5040 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5041 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5042 int origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5043
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5044 origpos = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5045
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5046 if (ISALPHA (s[pos]) || s[pos] == '_')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5047 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5048 /* The atom is unquoted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5049 pos++;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5050 while (ISALNUM (s[pos]) || s[pos] == '_')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5051 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5052 return pos - origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5053 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5054 else if (s[pos] == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5055 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5056 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5057
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5058 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5059 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5060 if (s[pos] == '\'')
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 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5063 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5064 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5065 else if (s[pos] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5066 /* Multiline quoted atoms are ignored. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5067 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5068 else if (s[pos] == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5069 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5070 if (s[pos+1] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5071 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5072 pos += 2;
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5075 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5076 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5077 return pos - origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5078 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5079 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5080 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5081 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5082
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5083
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5084 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5085
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5086 static char *scan_separators __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5087 static void analyse_regex __P((char *, bool));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5088 static void add_regex __P((char *, bool, language *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5089 static char *substitute __P((char *, char *, struct re_registers *));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5090
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5091 /* Take a string like "/blah/" and turn it into "blah", making sure
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5092 that the first and last characters are the same, and handling
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5093 quoted separator characters. Actually, stops on the occurrence of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5094 an unquoted separator. Also turns "\t" into a Tab character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5095 Returns pointer to terminating separator. Works in place. Null
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5096 terminates name string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5097 static char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5098 scan_separators (name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5099 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5100 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5101 char sep = name[0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5102 char *copyto = name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5103 bool quoted = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5105 for (++name; *name != '\0'; ++name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5106 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5107 if (quoted)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5108 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5109 if (*name == 't')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5110 *copyto++ = '\t';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5111 else if (*name == sep)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5112 *copyto++ = sep;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5113 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5114 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5115 /* Something else is quoted, so preserve the quote. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5116 *copyto++ = '\\';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5117 *copyto++ = *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5118 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5119 quoted = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5120 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5121 else if (*name == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5122 quoted = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5123 else if (*name == sep)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5124 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5125 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5126 *copyto++ = *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5127 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5128
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5129 /* Terminate copied string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5130 *copyto = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5131 return name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5132 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5133
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5134 /* 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
5135 thing. Same for each line of a regexp file. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5136 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5137 analyse_regex (regex_arg, ignore_case)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5138 char *regex_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5139 bool ignore_case;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5140 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5141 if (regex_arg == NULL)
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5142 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5143 free_patterns (); /* --no-regex: remove existing regexps */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5144 return;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5145 }
428
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 /* A real --regexp option or a line in a regexp file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5148 switch (regex_arg[0])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5149 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5150 /* Comments in regexp file or null arg to --regex. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5151 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5152 case ' ':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5153 case '\t':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5154 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5155
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5156 /* Read a regex file. This is recursive and may result in a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5157 loop, which will stop when the file descriptors are exhausted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5158 case '@':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5159 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5160 FILE *regexfp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5161 linebuffer regexbuf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5162 char *regexfile = regex_arg + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5164 /* regexfile is a file containing regexps, one per line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5165 regexfp = fopen (regexfile, "r");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5166 if (regexfp == NULL)
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 pfatal (regexfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5169 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5170 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5171 initbuffer (&regexbuf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5172 while (readline_internal (&regexbuf, regexfp) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5173 analyse_regex (regexbuf.buffer, ignore_case);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5174 free (regexbuf.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5175 fclose (regexfp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5176 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5177 break;
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 /* Regexp to be used for a specific language only. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5180 case '{':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5181 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5182 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5183 char *lang_name = regex_arg + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5184 char *cp;
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 for (cp = lang_name; *cp != '}'; cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5187 if (*cp == '\0')
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 error ("unterminated language name in regex: %s", regex_arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5190 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5191 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5192 *cp = '\0';
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5193 lang = get_language_from_langname (lang_name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5194 if (lang == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5195 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5196 add_regex (cp + 1, ignore_case, lang);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5197 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5198 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5199
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5200 /* Regexp to be used for any language. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5201 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5202 add_regex (regex_arg, ignore_case, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5203 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5204 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5205 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5207 /* Turn a name, which is an ed-style (but Emacs syntax) regular
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5208 expression, into a real regular expression by compiling it. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5209 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5210 add_regex (regexp_pattern, ignore_case, lang)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5211 char *regexp_pattern;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5212 bool ignore_case;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5213 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5214 {
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
5215 static struct re_pattern_buffer zeropattern;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5216 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5217 const char *err;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5218 struct re_pattern_buffer *patbuf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5219 pattern *pp;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5222 if (regexp_pattern[strlen(regexp_pattern)-1] != regexp_pattern[0])
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 error ("%s: unterminated regexp", regexp_pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5225 return;
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 name = scan_separators (regexp_pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5228 if (regexp_pattern[0] == '\0')
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 error ("null regexp", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5231 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5232 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5233 (void) scan_separators (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5234
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5235 patbuf = xnew (1, struct re_pattern_buffer);
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
5236 *patbuf = zeropattern;
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
5237 if (ignore_case)
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
5238 patbuf->translate = lc_trans; /* translation table to fold case */
428
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 err = re_compile_pattern (regexp_pattern, strlen (regexp_pattern), patbuf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5241 if (err != NULL)
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 error ("%s while compiling pattern", err);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5244 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5245 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5246
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5247 pp = p_head;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5248 p_head = xnew (1, pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5249 p_head->regex = savestr (regexp_pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5250 p_head->p_next = pp;
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5251 p_head->lang = lang;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5252 p_head->pat = patbuf;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5253 p_head->name_pattern = savestr (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5254 p_head->error_signaled = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5255 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5256
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 * Do the substitutions indicated by the regular expression and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5259 * arguments.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5260 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5261 static char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5262 substitute (in, out, regs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5263 char *in, *out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5264 struct re_registers *regs;
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 char *result, *t;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5267 int size, dig, diglen;
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 result = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5270 size = strlen (out);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5271
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5272 /* 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
5273 if (out[size - 1] == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5274 fatal ("pattern error in \"%s\"", out);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5275 for (t = etags_strchr (out, '\\');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5276 t != NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5277 t = etags_strchr (t + 2, '\\'))
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5278 if (ISDIGIT (t[1]))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5279 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5280 dig = t[1] - '0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5281 diglen = regs->end[dig] - regs->start[dig];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5282 size += diglen - 2;
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 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5285 size -= 1;
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 /* Allocate space and do the substitutions. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5288 result = xnew (size + 1, char);
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 for (t = result; *out != '\0'; out++)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5291 if (*out == '\\' && ISDIGIT (*++out))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5292 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5293 dig = *out - '0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5294 diglen = regs->end[dig] - regs->start[dig];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5295 strncpy (t, in + regs->start[dig], diglen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5296 t += diglen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5297 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5298 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5299 *t++ = *out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5300 *t = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5301
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5302 assert (t <= result + size && t - result == (int)strlen (result));
428
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 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5305 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5306
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5307 /* Deallocate all patterns. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5308 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5309 free_patterns ()
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 pattern *pp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5312 while (p_head != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5313 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5314 pp = p_head->p_next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5315 free (p_head->regex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5316 free (p_head->name_pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5317 free (p_head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5318 p_head = pp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5319 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5320 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5321 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5322 #endif /* ETAGS_REGEXPS */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5323
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5324
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5325 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5326 get_tag (bp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5327 register char *bp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5328 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5329 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5330
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5331 if (*bp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5332 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5333 /* Go till you get to white space or a syntactic break */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5334 for (cp = bp + 1;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5335 *cp != '\0' && *cp != '(' && *cp != ')' && !iswhite (*cp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5336 cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5337 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5338 pfnote (savenstr (bp, cp-bp), TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5339 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5340 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5341
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5342 /* Initialize a linebuffer for use */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5343 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5344 initbuffer (lbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5345 linebuffer *lbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5346 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5347 lbp->size = (DEBUG) ? 3 : 200;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5348 lbp->buffer = xnew (lbp->size, char);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5349 lbp->buffer[0] = '\0';
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5350 lbp->len = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5351 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5352
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5353 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5354 * Read a line of text from `stream' into `lbp', excluding the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5355 * 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
5356 * `stream', which is the length of the line including the newline.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5357 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5358 * 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
5359 * 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
5360 * 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
5361 * file).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5362 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5363 static long
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5364 readline_internal (lbp, stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5365 linebuffer *lbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5366 register FILE *stream;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5367 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5368 char *buffer = lbp->buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5369 register char *p = lbp->buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5370 register char *pend;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5371 int chars_deleted;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5372
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5373 pend = p + lbp->size; /* Separate to avoid 386/IX compiler bug. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5374
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5375 while (1)
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 register int c = getc (stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5378 if (p == pend)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5379 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5380 /* We're at the end of linebuffer: expand it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5381 lbp->size *= 2;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5382 xrnew (buffer, lbp->size, char);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5383 p += buffer - lbp->buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5384 pend = buffer + lbp->size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5385 lbp->buffer = buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5386 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5387 if (c == EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5388 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5389 *p = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5390 chars_deleted = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5391 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5392 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5393 if (c == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5394 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5395 if (p > buffer && p[-1] == '\r')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5396 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5397 p -= 1;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5398 #ifdef DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5399 /* Assume CRLF->LF translation will be performed by Emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5400 when loading this file, so CRs won't appear in the buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5401 It would be cleaner to compensate within Emacs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5402 however, Emacs does not know how many CRs were deleted
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5403 before any given point in the file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5404 chars_deleted = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5405 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5406 chars_deleted = 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5407 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5408 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5409 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5410 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5411 chars_deleted = 1;
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 = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5414 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5415 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5416 *p++ = c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5417 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5418 lbp->len = p - buffer;
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 return lbp->len + chars_deleted;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5421 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5422
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5423 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5424 * Like readline_internal, above, but in addition try to match the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5425 * input line against relevant regular expressions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5426 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5427 static long
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5428 readline (lbp, stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5429 linebuffer *lbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5430 FILE *stream;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5431 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5432 /* Read new line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5433 long result = readline_internal (lbp, stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5434 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5435 int match;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5436 pattern *pp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5437
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5438 /* Match against relevant patterns. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5439 if (lbp->len > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5440 for (pp = p_head; pp != NULL; pp = pp->p_next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5441 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5442 /* 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
5443 if (pp->lang != NULL && pp->lang != curlang)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5444 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5445
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5446 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
5447 switch (match)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5448 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5449 case -2:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5450 /* Some error. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5451 if (!pp->error_signaled)
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 error ("error while matching \"%s\"", pp->regex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5454 pp->error_signaled = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5455 }
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 case -1:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5458 /* No match. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5459 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5460 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5461 /* Match occurred. Construct a tag. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5462 if (pp->name_pattern[0] != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5463 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5464 /* Make a named tag. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5465 char *name = substitute (lbp->buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5466 pp->name_pattern, &pp->regs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5467 if (name != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5468 pfnote (name, TRUE, lbp->buffer, match, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5469 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5470 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5471 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5472 /* Make an unnamed tag. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5473 pfnote ((char *)NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5474 lbp->buffer, match, lineno, linecharno);
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 break;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5479 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5480
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5481 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5482 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5483
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5484
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5485 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5486 * Return a pointer to a space of size strlen(cp)+1 allocated
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5487 * with xnew where the string CP has been copied.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5488 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5489 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5490 savestr (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5491 char *cp;
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 return savenstr (cp, strlen (cp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5494 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5495
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5496 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5497 * 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
5498 * 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
5499 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5500 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5501 savenstr (cp, len)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5502 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5503 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5504 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5505 register char *dp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5506
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5507 dp = xnew (len + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5508 strncpy (dp, cp, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5509 dp[len] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5510 return dp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5511 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5512
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5513 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5514 * Return the ptr in sp at which the character c last
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5515 * appears; NULL if not found
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5516 *
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5517 * Identical to POSIX strrchr, included for portability.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5518 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5519 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5520 etags_strrchr (sp, c)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5521 register const char *sp;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5522 register int c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5523 {
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 432
diff changeset
5524 register const char *r;
428
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 r = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5527 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5528 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5529 if (*sp == c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5530 r = sp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5531 } while (*sp++);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5532 return (char *)r;
428
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5535
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5536 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5537 * Return the ptr in sp at which the character c first
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5538 * appears; NULL if not found
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5539 *
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5540 * Identical to POSIX strchr, included for portability.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5541 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5542 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5543 etags_strchr (sp, c)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5544 register const char *sp;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5545 register int c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5546 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5547 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5548 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5549 if (*sp == c)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5550 return (char *)sp;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5551 } while (*sp++);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5552 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5553 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5554
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5555 /* Skip spaces, return new pointer. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5556 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5557 skip_spaces (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5558 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5559 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5560 while (iswhite (*cp))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5561 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5562 return cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5563 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5564
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5565 /* Skip non spaces, return new pointer. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5566 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5567 skip_non_spaces (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5568 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5569 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5570 while (*cp != '\0' && !iswhite (*cp))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5571 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5572 return cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5573 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5574
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5575 /* Print error message and exit. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5576 void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5577 fatal (s1, s2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5578 char *s1, *s2;
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 error (s1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5581 exit (BAD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5582 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5583
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5584 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5585 pfatal (s1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5586 char *s1;
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 perror (s1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5589 exit (BAD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5590 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5591
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5592 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5593 suggest_asking_for_help ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5594 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5595 fprintf (stderr, "\tTry `%s %s' for a complete list of options.\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5596 progname,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5597 #ifdef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5598 "--help"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5599 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5600 "-h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5601 #endif
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 exit (BAD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5604 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5605
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5606 /* 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
5607 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5608 error (s1, s2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5609 const char *s1, *s2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5610 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5611 fprintf (stderr, "%s: ", progname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5612 fprintf (stderr, s1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5613 fprintf (stderr, "\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5614 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5615
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5616 /* Return a newly-allocated string whose contents
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5617 concatenate those of s1, s2, s3. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5618 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5619 concat (s1, s2, s3)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5620 char *s1, *s2, *s3;
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 int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5623 char *result = xnew (len1 + len2 + len3 + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5624
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5625 strcpy (result, s1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5626 strcpy (result + len1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5627 strcpy (result + len1 + len2, s3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5628 result[len1 + len2 + len3] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5630 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5631 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5632
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5633
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5634 /* 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
5635 guess the buffer size in advance. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5636 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5637 etags_getcwd ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5638 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5639 #ifdef HAVE_GETCWD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5640 int bufsize = 200;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5641 char *path = xnew (bufsize, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5642
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5643 while (getcwd (path, bufsize) == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5644 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5645 if (errno != ERANGE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5646 pfatal ("getcwd");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5647 bufsize *= 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5648 free (path);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5649 path = xnew (bufsize, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5650 }
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 canonicalize_filename (path);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5653 return path;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5654
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5655 #else /* not HAVE_GETCWD */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5656 #if MSDOS
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5657
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5658 char *p, path[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5659
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5660 getwd (path);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5661
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5662 for (p = path; *p != '\0'; p++)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5663 if (*p == '\\')
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5664 *p = '/';
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5665 else
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5666 *p = lowcase (*p);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5667
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5668 return strdup (path);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5669 #else /* not MSDOS */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5670 linebuffer path;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5671 FILE *pipe;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5672
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5673 initbuffer (&path);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5674 pipe = (FILE *) popen ("pwd 2>/dev/null", "r");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5675 if (pipe == NULL || readline_internal (&path, pipe) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5676 pfatal ("pwd");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5677 pclose (pipe);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5678
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5679 return path.buffer;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5680 #endif /* not MSDOS */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5681 #endif /* not HAVE_GETCWD */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5682 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5683
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5684 /* Return a newly allocated string containing the file name of FILE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5685 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
5686 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5687 relative_filename (file, dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5688 char *file, *dir;
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 char *fp, *dp, *afn, *res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5691 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5692
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5693 /* Find the common root of file and dir (with a trailing slash). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5694 afn = absolute_filename (file, cwd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5695 fp = afn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5696 dp = dir;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5697 while (*fp++ == *dp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5698 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5699 fp--, dp--; /* back to the first differing char */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5700 #ifdef DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5701 if (fp == afn && afn[0] != '/') /* cannot build a relative name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5702 return afn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5703 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5704 do /* look at the equal chars until '/' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5705 fp--, dp--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5706 while (*fp != '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5707
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5708 /* Build a sequence of "../" strings for the resulting relative file name. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5709 i = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5710 while ((dp = etags_strchr (dp + 1, '/')) != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5711 i += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5712 res = xnew (3*i + strlen (fp + 1) + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5713 res[0] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5714 while (i-- > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5715 strcat (res, "../");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5716
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5717 /* 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
5718 strcat (res, fp + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5719 free (afn);
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 res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5722 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5723
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5724 /* Return a newly allocated string containing the absolute file name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5725 of FILE given DIR (which should end with a slash). */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5726 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5727 absolute_filename (file, dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5728 char *file, *dir;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5729 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5730 char *slashp, *cp, *res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5731
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5732 if (filename_is_absolute (file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5733 res = savestr (file);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5734 #ifdef DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5735 /* We don't support non-absolute file names with a drive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5736 letter, like `d:NAME' (it's too much hassle). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5737 else if (file[1] == ':')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5738 fatal ("%s: relative file names with drive letters not supported", file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5739 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5740 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5741 res = concat (dir, file, "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5742
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5743 /* Delete the "/dirname/.." and "/." substrings. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5744 slashp = etags_strchr (res, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5745 while (slashp != NULL && slashp[0] != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5746 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5747 if (slashp[1] == '.')
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 if (slashp[2] == '.'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5750 && (slashp[3] == '/' || slashp[3] == '\0'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5751 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5752 cp = slashp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5753 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5754 cp--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5755 while (cp >= res && !filename_is_absolute (cp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5756 if (cp < res)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5757 cp = slashp; /* the absolute name begins with "/.." */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5758 #ifdef DOS_NT
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5759 /* Under MSDOS and NT we get `d:/NAME' as absolute
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5760 file name, so the luser could say `d:/../NAME'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5761 We silently treat this as `d:/NAME'. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5762 else if (cp[0] != '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5763 cp = slashp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5764 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5765 strcpy (cp, slashp + 3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5766 slashp = cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5767 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5768 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5769 else if (slashp[2] == '/' || slashp[2] == '\0')
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 strcpy (slashp, slashp + 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5772 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5773 }
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 slashp = etags_strchr (slashp + 1, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5777 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5778
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5779 if (res[0] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5780 return savestr ("/");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5781 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5782 return res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5783 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5784
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5785 /* Return a newly allocated string containing the absolute
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5786 file name of dir where FILE resides given DIR (which should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5787 end with a slash). */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5788 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5789 absolute_dirname (file, dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5790 char *file, *dir;
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 char *slashp, *res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5793 char save;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5794
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5795 canonicalize_filename (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5796 slashp = etags_strrchr (file, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5797 if (slashp == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5798 return savestr (dir);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5799 save = slashp[1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5800 slashp[1] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5801 res = absolute_filename (file, dir);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5802 slashp[1] = save;
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 return res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5805 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5806
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5807 /* Whether the argument string is an absolute file name. The argument
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5808 string must have been canonicalized with canonicalize_filename. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5809 static bool
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5810 filename_is_absolute (fn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5811 char *fn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5812 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5813 return (fn[0] == '/'
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5814 #ifdef DOS_NT
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5815 || (ISALPHA(fn[0]) && fn[1] == ':' && fn[2] == '/')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5816 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5817 );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5818 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5819
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5820 /* Translate backslashes into slashes. Works in place. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5821 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5822 canonicalize_filename (fn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5823 register char *fn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5824 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5825 #ifdef DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5826 /* Canonicalize drive letter case. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5827 if (fn[0] != '\0' && fn[1] == ':' && ISLOWER (fn[0]))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5828 fn[0] = upcase (fn[0]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5829 /* Convert backslashes to slashes. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5830 for (; *fn != '\0'; fn++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5831 if (*fn == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5832 *fn = '/';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5833 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5834 /* No action. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5835 fn = NULL; /* shut up the compiler */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5836 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5837 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5838
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5839 /* 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
5840 static void
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5841 linebuffer_setlen (lbp, toksize)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5842 linebuffer *lbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5843 int toksize;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5844 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5845 while (lbp->size <= toksize)
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->size *= 2;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5848 xrnew (lbp->buffer, lbp->size, char);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5849 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5850 lbp->len = toksize;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5851 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5852
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5853 /* 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
5854 PTR
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5855 xmalloc (size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5856 unsigned int size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5857 {
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5858 PTR result = (PTR) malloc (size);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5859 if (result == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5860 fatal ("virtual memory exhausted", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5861 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5862 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5863
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5864 PTR
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5865 xrealloc (ptr, size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5866 char *ptr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5867 unsigned int size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5868 {
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5869 PTR result = (PTR) realloc (ptr, size);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5870 if (result == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5871 fatal ("virtual memory exhausted", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5872 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5873 }
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5874
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5875 /*
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5876 * Local Variables:
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5877 * c-indentation-style: gnu
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5878 * indent-tabs-mode: t
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5879 * tab-width: 8
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5880 * 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
5881 * End:
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5882 */