Deleted Added
sdiff udiff text old ( 87249 ) new ( 87628 )
full compact
1/*
2 * Copyright (c) 1987, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
35
36__FBSDID("$FreeBSD: head/usr.bin/ctags/fortran.c 87249 2001-12-03 00:07:59Z markm $");
37
38#ifndef lint
39static const char sccsid[] = "@(#)fortran.c 8.3 (Berkeley) 4/2/94";
40#endif
41
42#include <ctype.h>
43#include <limits.h>
44#include <stdio.h>
45#include <string.h>
46
47#include "ctags.h"
48
49static void takeprec __P((void));
50
51char *lbp; /* line buffer pointer */
52
53int
54PF_funcs()
55{
56 bool pfcnt; /* pascal/fortran functions found */
57 char *cp;
58 char tok[MAXTOKEN];
59
60 for (pfcnt = NO;;) {
61 lineftell = ftell(inf);
62 if (!fgets(lbuf, sizeof(lbuf), inf))
63 return (pfcnt);
64 ++lineno;
65 lbp = lbuf;
66 if (*lbp == '%') /* Ratfor escape to fortran */
67 ++lbp;
68 for (; isspace(*lbp); ++lbp)
69 continue;
70 if (!*lbp)
71 continue;
72 switch (*lbp | ' ') { /* convert to lower-case */
73 case 'c':
74 if (cicmp("complex") || cicmp("character"))
75 takeprec();
76 break;
77 case 'd':
78 if (cicmp("double")) {
79 for (; isspace(*lbp); ++lbp)
80 continue;
81 if (!*lbp)
82 continue;
83 if (cicmp("precision"))
84 break;
85 continue;
86 }
87 break;
88 case 'i':
89 if (cicmp("integer"))
90 takeprec();
91 break;
92 case 'l':
93 if (cicmp("logical"))
94 takeprec();
95 break;
96 case 'r':
97 if (cicmp("real"))
98 takeprec();
99 break;
100 }
101 for (; isspace(*lbp); ++lbp)
102 continue;
103 if (!*lbp)
104 continue;
105 switch (*lbp | ' ') {
106 case 'f':
107 if (cicmp("function"))
108 break;
109 continue;
110 case 'p':
111 if (cicmp("program") || cicmp("procedure"))
112 break;
113 continue;
114 case 's':
115 if (cicmp("subroutine"))
116 break;
117 default:
118 continue;
119 }
120 for (; isspace(*lbp); ++lbp)
121 continue;
122 if (!*lbp)
123 continue;
124 for (cp = lbp + 1; *cp && intoken(*cp); ++cp)
125 continue;
126 if ((cp = lbp + 1))
127 continue;
128 *cp = EOS;
129 (void)strcpy(tok, lbp);
130 getline(); /* process line for ex(1) */
131 pfnote(tok, lineno);
132 pfcnt = YES;
133 }
134 /*NOTREACHED*/
135}
136
137/*
138 * cicmp --
139 * do case-independent strcmp
140 */
141int
142cicmp(cp)
143 const char *cp;
144{
145 int len;
146 char *bp;
147
148 for (len = 0, bp = lbp; *cp && (*cp &~ ' ') == (*bp++ &~ ' ');
149 ++cp, ++len)
150 continue;
151 if (!*cp) {
152 lbp += len;
153 return (YES);
154 }
155 return (NO);
156}
157
158static void
159takeprec()
160{
161 for (; isspace(*lbp); ++lbp)
162 continue;
163 if (*lbp == '*') {
164 for (++lbp; isspace(*lbp); ++lbp)
165 continue;
166 if (!isdigit(*lbp))
167 --lbp; /* force failure */
168 else
169 while (isdigit(*++lbp))
170 continue;
171 }
172}