xref: /original-bsd/usr.bin/ctags/lisp.c (revision e58c8952)
1 /*
2  * Copyright (c) 1987, 1993, 1994
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)lisp.c	8.3 (Berkeley) 04/02/94";
10 #endif /* not lint */
11 
12 #include <ctype.h>
13 #include <limits.h>
14 #include <stdio.h>
15 #include <string.h>
16 
17 #include "ctags.h"
18 
19 /*
20  * lisp tag functions
21  * just look for (def or (DEF
22  */
23 void
24 l_entries()
25 {
26 	int	special;
27 	char	*cp;
28 	char	savedc;
29 	char	tok[MAXTOKEN];
30 
31 	for (;;) {
32 		lineftell = ftell(inf);
33 		if (!fgets(lbuf, sizeof(lbuf), inf))
34 			return;
35 		++lineno;
36 		lbp = lbuf;
37 		if (!cicmp("(def"))
38 			continue;
39 		special = NO;
40 		switch(*lbp | ' ') {
41 		case 'm':
42 			if (cicmp("method"))
43 				special = YES;
44 			break;
45 		case 'w':
46 			if (cicmp("wrapper") || cicmp("whopper"))
47 				special = YES;
48 		}
49 		for (; !isspace(*lbp); ++lbp)
50 			continue;
51 		for (; isspace(*lbp); ++lbp)
52 			continue;
53 		for (cp = lbp; *cp && *cp != '\n'; ++cp)
54 			continue;
55 		*cp = EOS;
56 		if (special) {
57 			if (!(cp = strchr(lbp, ')')))
58 				continue;
59 			for (; cp >= lbp && *cp != ':'; --cp)
60 				continue;
61 			if (cp < lbp)
62 				continue;
63 			lbp = cp;
64 			for (; *cp && *cp != ')' && *cp != ' '; ++cp)
65 				continue;
66 		}
67 		else
68 			for (cp = lbp + 1;
69 			    *cp && *cp != '(' && *cp != ' '; ++cp)
70 				continue;
71 		savedc = *cp;
72 		*cp = EOS;
73 		(void)strcpy(tok, lbp);
74 		*cp = savedc;
75 		getline();
76 		pfnote(tok, lineno);
77 	}
78 	/*NOTREACHED*/
79 }
80