Correct BSD License clause numbering from 1-2-4 to 1-2-3.
[dragonfly.git] / usr.bin / ctags / lisp.c
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. Neither the name of the University nor the names of its contributors
14  *    may be used to endorse or promote products derived from this software
15  *    without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * @(#)lisp.c   8.3 (Berkeley) 4/2/94
30  * $FreeBSD: src/usr.bin/ctags/lisp.c,v 1.2.6.2 2002/07/30 00:55:07 tjr Exp $
31  * $DragonFly: src/usr.bin/ctags/lisp.c,v 1.2 2003/06/17 04:29:25 dillon Exp $
32  */
33
34 #include <ctype.h>
35 #include <limits.h>
36 #include <stdio.h>
37 #include <string.h>
38
39 #include "ctags.h"
40
41 /*
42  * lisp tag functions
43  * just look for (def or (DEF
44  */
45 void
46 l_entries(void)
47 {
48         int     special;
49         char    *cp;
50         char    savedc;
51         char    tok[MAXTOKEN];
52
53         for (;;) {
54                 lineftell = ftell(inf);
55                 if (!fgets(lbuf, sizeof(lbuf), inf))
56                         return;
57                 ++lineno;
58                 lbp = lbuf;
59                 if (!cicmp("(def"))
60                         continue;
61                 special = NO;
62                 switch(*lbp | ' ') {
63                 case 'm':
64                         if (cicmp("method"))
65                                 special = YES;
66                         break;
67                 case 'w':
68                         if (cicmp("wrapper") || cicmp("whopper"))
69                                 special = YES;
70                 }
71                 for (; !isspace(*lbp); ++lbp)
72                         continue;
73                 for (; isspace(*lbp); ++lbp)
74                         continue;
75                 for (cp = lbp; *cp && *cp != '\n'; ++cp)
76                         continue;
77                 *cp = EOS;
78                 if (special) {
79                         if (!(cp = strchr(lbp, ')')))
80                                 continue;
81                         for (; cp >= lbp && *cp != ':'; --cp)
82                                 continue;
83                         if (cp < lbp)
84                                 continue;
85                         lbp = cp;
86                         for (; *cp && *cp != ')' && *cp != ' '; ++cp)
87                                 continue;
88                 }
89                 else
90                         for (cp = lbp + 1;
91                             *cp && *cp != '(' && *cp != ' '; ++cp)
92                                 continue;
93                 savedc = *cp;
94                 *cp = EOS;
95                 (void)strlcpy(tok, lbp, sizeof(tok));   /* possible trunc */
96                 *cp = savedc;
97                 getline();
98                 pfnote(tok, lineno);
99         }
100         /*NOTREACHED*/
101 }