Index: stable/4/usr.bin/ctags/Makefile =================================================================== --- stable/4/usr.bin/ctags/Makefile (revision 83601) +++ stable/4/usr.bin/ctags/Makefile (revision 83602) @@ -1,8 +1,9 @@ # @(#)Makefile 8.1 (Berkeley) 6/6/93 +# $FreeBSD$ PROG= ctags CFLAGS+=-Wall CFLAGS+=-I${.CURDIR} SRCS= C.c ctags.c fortran.c lisp.c print.c tree.c yacc.c .include Index: stable/4/usr.bin/ctags/ctags.c =================================================================== --- stable/4/usr.bin/ctags/ctags.c (revision 83601) +++ stable/4/usr.bin/ctags/ctags.c (revision 83602) @@ -1,278 +1,282 @@ /* * Copyright (c) 1987, 1993, 1994, 1995 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint static const char copyright[] = "@(#) Copyright (c) 1987, 1993, 1994, 1995\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint +#if 0 static const char sccsid[] = "@(#)ctags.c 8.4 (Berkeley) 2/7/95"; +#endif +static const char rcsid[] = + "$FreeBSD$"; #endif /* not lint */ #include #include #include #include #include #include #include "ctags.h" /* * ctags: create a tags file */ NODE *head; /* head of the sorted binary tree */ /* boolean "func" (see init()) */ bool _wht[256], _etk[256], _itk[256], _btk[256], _gd[256]; FILE *inf; /* ioptr for current input file */ FILE *outf; /* ioptr for tags file */ long lineftell; /* ftell after getc( inf ) == '\n' */ int lineno; /* line number of current line */ int dflag; /* -d: non-macro defines */ int tflag; /* -t: create tags for typedefs */ int vflag; /* -v: vgrind style index output */ int wflag; /* -w: suppress warnings */ int xflag; /* -x: cxref style output */ char *curfile; /* current input file name */ char searchar = '/'; /* use /.../ searches by default */ char lbuf[LINE_MAX]; void init __P((void)); void find_entries __P((char *)); static void usage __P((void)); int main(argc, argv) int argc; char **argv; { static char *outfile = "tags"; /* output file */ int aflag; /* -a: append to tags */ int uflag; /* -u: update tags */ int exit_val; /* exit value */ int step; /* step through args */ int ch; /* getopts char */ char cmd[100]; /* too ugly to explain */ aflag = uflag = NO; while ((ch = getopt(argc, argv, "BFadf:tuwvx")) != -1) switch(ch) { case 'B': searchar = '?'; break; case 'F': searchar = '/'; break; case 'a': aflag++; break; case 'd': dflag++; break; case 'f': outfile = optarg; break; case 't': tflag++; break; case 'u': uflag++; break; case 'w': wflag++; break; case 'v': vflag++; case 'x': xflag++; break; case '?': default: usage(); } argv += optind; argc -= optind; if (!argc) usage(); init(); for (exit_val = step = 0; step < argc; ++step) if (!(inf = fopen(argv[step], "r"))) { warn("%s", argv[step]); exit_val = 1; } else { curfile = argv[step]; find_entries(argv[step]); (void)fclose(inf); } if (head) { if (xflag) put_entries(head); else { if (uflag) { for (step = 0; step < argc; step++) { (void)sprintf(cmd, "mv %s OTAGS; fgrep -v '\t%s\t' OTAGS >%s; rm OTAGS", outfile, argv[step], outfile); system(cmd); } ++aflag; } if (!(outf = fopen(outfile, aflag ? "a" : "w"))) err(exit_val, "%s", outfile); put_entries(head); (void)fclose(outf); if (uflag) { (void)sprintf(cmd, "sort -o %s %s", outfile, outfile); system(cmd); } } } exit(exit_val); } static void usage() { (void)fprintf(stderr, "usage: ctags [-BFadtuwvx] [-f tagsfile] file ...\n"); exit(1); } /* * init -- * this routine sets up the boolean psuedo-functions which work by * setting boolean flags dependent upon the corresponding character. * Every char which is NOT in that string is false with respect to * the pseudo-function. Therefore, all of the array "_wht" is NO * by default and then the elements subscripted by the chars in * CWHITE are set to YES. Thus, "_wht" of a char is YES if it is in * the string CWHITE, else NO. */ void init() { int i; unsigned char *sp; for (i = 0; i < 256; i++) { _wht[i] = _etk[i] = _itk[i] = _btk[i] = NO; _gd[i] = YES; } #define CWHITE " \f\t\n" for (sp = CWHITE; *sp; sp++) /* white space chars */ _wht[*sp] = YES; #define CTOKEN " \t\n\"'#()[]{}=-+%*/&|^~!<>;,.:?" for (sp = CTOKEN; *sp; sp++) /* token ending chars */ _etk[*sp] = YES; #define CINTOK "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz0123456789" for (sp = CINTOK; *sp; sp++) /* valid in-token chars */ _itk[*sp] = YES; #define CBEGIN "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz" for (sp = CBEGIN; *sp; sp++) /* token starting chars */ _btk[*sp] = YES; #define CNOTGD ",;" for (sp = CNOTGD; *sp; sp++) /* invalid after-function chars */ _gd[*sp] = NO; } /* * find_entries -- * this routine opens the specified file and calls the function * which searches the file. */ void find_entries(file) char *file; { char *cp; lineno = 0; /* should be 1 ?? KB */ if ((cp = strrchr(file, '.'))) { if (cp[1] == 'l' && !cp[2]) { int c; for (;;) { if (GETC(==, EOF)) return; if (!iswhite(c)) { rewind(inf); break; } } #define LISPCHR ";([" /* lisp */ if (strchr(LISPCHR, c)) { l_entries(); return; } /* lex */ else { /* * we search all 3 parts of a lex file * for C references. This may be wrong. */ toss_yysec(); (void)strcpy(lbuf, "%%$"); pfnote("yylex", lineno); rewind(inf); } } /* yacc */ else if (cp[1] == 'y' && !cp[2]) { /* * we search only the 3rd part of a yacc file * for C references. This may be wrong. */ toss_yysec(); (void)strcpy(lbuf, "%%$"); pfnote("yyparse", lineno); y_entries(); } /* fortran */ else if ((cp[1] != 'c' && cp[1] != 'h') && !cp[2]) { if (PF_funcs()) return; rewind(inf); } } /* C */ c_entries(); } Index: stable/4/usr.bin/ctags/fortran.c =================================================================== --- stable/4/usr.bin/ctags/fortran.c (revision 83601) +++ stable/4/usr.bin/ctags/fortran.c (revision 83602) @@ -1,168 +1,172 @@ /* * Copyright (c) 1987, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint +#if 0 static const char sccsid[] = "@(#)fortran.c 8.3 (Berkeley) 4/2/94"; +#endif +static const char rcsid[] = + "$FreeBSD$"; #endif /* not lint */ #include #include #include #include #include "ctags.h" static void takeprec __P((void)); char *lbp; /* line buffer pointer */ int PF_funcs() { bool pfcnt; /* pascal/fortran functions found */ char *cp; char tok[MAXTOKEN]; for (pfcnt = NO;;) { lineftell = ftell(inf); if (!fgets(lbuf, sizeof(lbuf), inf)) return (pfcnt); ++lineno; lbp = lbuf; if (*lbp == '%') /* Ratfor escape to fortran */ ++lbp; for (; isspace(*lbp); ++lbp) continue; if (!*lbp) continue; switch (*lbp | ' ') { /* convert to lower-case */ case 'c': if (cicmp("complex") || cicmp("character")) takeprec(); break; case 'd': if (cicmp("double")) { for (; isspace(*lbp); ++lbp) continue; if (!*lbp) continue; if (cicmp("precision")) break; continue; } break; case 'i': if (cicmp("integer")) takeprec(); break; case 'l': if (cicmp("logical")) takeprec(); break; case 'r': if (cicmp("real")) takeprec(); break; } for (; isspace(*lbp); ++lbp) continue; if (!*lbp) continue; switch (*lbp | ' ') { case 'f': if (cicmp("function")) break; continue; case 'p': if (cicmp("program") || cicmp("procedure")) break; continue; case 's': if (cicmp("subroutine")) break; default: continue; } for (; isspace(*lbp); ++lbp) continue; if (!*lbp) continue; for (cp = lbp + 1; *cp && intoken(*cp); ++cp) continue; if ((cp = lbp + 1)) continue; *cp = EOS; (void)strcpy(tok, lbp); getline(); /* process line for ex(1) */ pfnote(tok, lineno); pfcnt = YES; } /*NOTREACHED*/ } /* * cicmp -- * do case-independent strcmp */ int cicmp(cp) char *cp; { int len; char *bp; for (len = 0, bp = lbp; *cp && (*cp &~ ' ') == (*bp++ &~ ' '); ++cp, ++len) continue; if (!*cp) { lbp += len; return (YES); } return (NO); } static void takeprec() { for (; isspace(*lbp); ++lbp) continue; if (*lbp == '*') { for (++lbp; isspace(*lbp); ++lbp) continue; if (!isdigit(*lbp)) --lbp; /* force failure */ else while (isdigit(*++lbp)) continue; } } Index: stable/4/usr.bin/ctags/lisp.c =================================================================== --- stable/4/usr.bin/ctags/lisp.c (revision 83601) +++ stable/4/usr.bin/ctags/lisp.c (revision 83602) @@ -1,105 +1,109 @@ /* * Copyright (c) 1987, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint +#if 0 static const char sccsid[] = "@(#)lisp.c 8.3 (Berkeley) 4/2/94"; +#endif +static const char rcsid[] = + "$FreeBSD$"; #endif /* not lint */ #include #include #include #include #include "ctags.h" /* * lisp tag functions * just look for (def or (DEF */ void l_entries() { int special; char *cp; char savedc; char tok[MAXTOKEN]; for (;;) { lineftell = ftell(inf); if (!fgets(lbuf, sizeof(lbuf), inf)) return; ++lineno; lbp = lbuf; if (!cicmp("(def")) continue; special = NO; switch(*lbp | ' ') { case 'm': if (cicmp("method")) special = YES; break; case 'w': if (cicmp("wrapper") || cicmp("whopper")) special = YES; } for (; !isspace(*lbp); ++lbp) continue; for (; isspace(*lbp); ++lbp) continue; for (cp = lbp; *cp && *cp != '\n'; ++cp) continue; *cp = EOS; if (special) { if (!(cp = strchr(lbp, ')'))) continue; for (; cp >= lbp && *cp != ':'; --cp) continue; if (cp < lbp) continue; lbp = cp; for (; *cp && *cp != ')' && *cp != ' '; ++cp) continue; } else for (cp = lbp + 1; *cp && *cp != '(' && *cp != ' '; ++cp) continue; savedc = *cp; *cp = EOS; (void)strcpy(tok, lbp); *cp = savedc; getline(); pfnote(tok, lineno); } /*NOTREACHED*/ } Index: stable/4/usr.bin/ctags/print.c =================================================================== --- stable/4/usr.bin/ctags/print.c (revision 83601) +++ stable/4/usr.bin/ctags/print.c (revision 83602) @@ -1,115 +1,119 @@ /* * Copyright (c) 1987, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint +#if 0 static const char sccsid[] = "@(#)print.c 8.3 (Berkeley) 4/2/94"; +#endif +static const char rcsid[] = + "$FreeBSD$"; #endif /* not lint */ #include #include #include #include #include #include "ctags.h" /* * getline -- * get the line the token of interest occurred on, * prepare it for printing. */ void getline() { long saveftell; int c; int cnt; char *cp; saveftell = ftell(inf); (void)fseek(inf, lineftell, L_SET); if (xflag) for (cp = lbuf; GETC(!=, EOF) && c != '\n'; *cp++ = c) continue; /* * do all processing here, so we don't step through the * line more than once; means you don't call this routine * unless you're sure you've got a keeper. */ else for (cnt = 0, cp = lbuf; GETC(!=, EOF) && cnt < ENDLINE; ++cnt) { if (c == '\\') { /* backslashes */ if (cnt > ENDLINE - 2) break; *cp++ = '\\'; *cp++ = '\\'; ++cnt; } else if (c == (int)searchar) { /* search character */ if (cnt > ENDLINE - 2) break; *cp++ = '\\'; *cp++ = c; ++cnt; } else if (c == '\n') { /* end of keep */ *cp++ = '$'; /* can find whole line */ break; } else *cp++ = c; } *cp = EOS; (void)fseek(inf, saveftell, L_SET); } /* * put_entries -- * write out the tags */ void put_entries(node) NODE *node; { if (node->left) put_entries(node->left); if (vflag) printf("%s %s %d\n", node->entry, node->file, (node->lno + 63) / 64); else if (xflag) - printf("%-16s%4d %-16s %s\n", + printf("%-16s %4d %-16s %s\n", node->entry, node->lno, node->file, node->pat); else fprintf(outf, "%s\t%s\t%c^%s%c\n", node->entry, node->file, searchar, node->pat, searchar); if (node->right) put_entries(node->right); } Index: stable/4/usr.bin/ctags/tree.c =================================================================== --- stable/4/usr.bin/ctags/tree.c (revision 83601) +++ stable/4/usr.bin/ctags/tree.c (revision 83602) @@ -1,135 +1,139 @@ /* * Copyright (c) 1987, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint +#if 0 static const char sccsid[] = "@(#)tree.c 8.3 (Berkeley) 4/2/94"; +#endif +static const char rcsid[] = + "$FreeBSD$"; #endif /* not lint */ #include #include #include #include #include #include "ctags.h" static void add_node __P((NODE *, NODE *)); static void free_tree __P((NODE *)); /* * pfnote -- * enter a new node in the tree */ void pfnote(name, ln) char *name; int ln; { NODE *np; char *fp; char nbuf[MAXTOKEN]; /*NOSTRICT*/ if (!(np = (NODE *)malloc(sizeof(NODE)))) { warnx("too many entries to sort"); put_entries(head); free_tree(head); /*NOSTRICT*/ if (!(head = np = (NODE *)malloc(sizeof(NODE)))) err(1, "out of space"); } if (!xflag && !strcmp(name, "main")) { if (!(fp = strrchr(curfile, '/'))) fp = curfile; else ++fp; (void)sprintf(nbuf, "M%s", fp); fp = strrchr(nbuf, '.'); if (fp && !fp[2]) *fp = EOS; name = nbuf; } if (!(np->entry = strdup(name))) err(1, NULL); np->file = curfile; np->lno = ln; np->left = np->right = 0; if (!(np->pat = strdup(lbuf))) err(1, NULL); if (!head) head = np; else add_node(np, head); } static void add_node(node, cur_node) NODE *node, *cur_node; { int dif; dif = strcmp(node->entry, cur_node->entry); if (!dif) { if (node->file == cur_node->file) { if (!wflag) fprintf(stderr, "Duplicate entry in file %s, line %d: %s\nSecond entry ignored\n", node->file, lineno, node->entry); return; } if (!cur_node->been_warned) if (!wflag) fprintf(stderr, "Duplicate entry in files %s and %s: %s (Warning only)\n", node->file, cur_node->file, node->entry); cur_node->been_warned = YES; } else if (dif < 0) if (cur_node->left) add_node(node, cur_node->left); else cur_node->left = node; else if (cur_node->right) add_node(node, cur_node->right); else cur_node->right = node; } static void free_tree(node) NODE *node; { while (node) { if (node->right) free_tree(node->right); free(node); node = node->left; } } Index: stable/4/usr.bin/ctags/yacc.c =================================================================== --- stable/4/usr.bin/ctags/yacc.c (revision 83601) +++ stable/4/usr.bin/ctags/yacc.c (revision 83602) @@ -1,151 +1,155 @@ /* * Copyright (c) 1987, 1993, 1994 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #ifndef lint +#if 0 static const char sccsid[] = "@(#)yacc.c 8.3 (Berkeley) 4/2/94"; +#endif +static const char rcsid[] = + "$FreeBSD$"; #endif /* not lint */ #include #include #include #include #include "ctags.h" /* * y_entries: * find the yacc tags and put them in. */ void y_entries() { int c; char *sp; bool in_rule; char tok[MAXTOKEN]; in_rule = NO; while (GETC(!=, EOF)) switch (c) { case '\n': SETLINE; /* FALLTHROUGH */ case ' ': case '\f': case '\r': case '\t': break; case '{': if (skip_key('}')) in_rule = NO; break; case '\'': case '"': if (skip_key(c)) in_rule = NO; break; case '%': if (GETC(==, '%')) return; (void)ungetc(c, inf); break; case '/': if (GETC(==, '*')) skip_comment(); else (void)ungetc(c, inf); break; case '|': case ';': in_rule = NO; break; default: if (in_rule || (!isalpha(c) && c != '.' && c != '_')) break; sp = tok; *sp++ = c; while (GETC(!=, EOF) && (intoken(c) || c == '.')) *sp++ = c; *sp = EOS; getline(); /* may change before ':' */ while (iswhite(c)) { if (c == '\n') SETLINE; if (GETC(==, EOF)) return; } if (c == ':') { pfnote(tok, lineno); in_rule = YES; } else (void)ungetc(c, inf); } } /* * toss_yysec -- * throw away lines up to the next "\n%%\n" */ void toss_yysec() { int c; /* read character */ int state; /* * state == 0 : waiting * state == 1 : received a newline * state == 2 : received first % * state == 3 : recieved second % */ lineftell = ftell(inf); for (state = 0; GETC(!=, EOF);) switch (c) { case '\n': ++lineno; lineftell = ftell(inf); if (state == 3) /* done! */ return; state = 1; /* start over */ break; case '%': if (state) /* if 1 or 2 */ ++state; /* goto 3 */ break; default: state = 0; /* reset */ break; } }