prettyness police
[unix-history] / usr / src / usr.bin / ctags / ctags.c
index 69a06b2..98433cc 100644 (file)
-static char *sccsid = "@(#)ctags.c     4.3 (Berkeley) 11/24/80";
-#include <stdio.h>
-#include <ctype.h>
-
 /*
 /*
- * ctags: create a tags file
+ * Copyright (c) 1987, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * %sccs.include.redist.c%
  */
 
  */
 
-#define        reg     register
-#define        logical char
+#ifndef lint
+static char copyright[] =
+"@(#) Copyright (c) 1987, 1993\n\
+       The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
 
 
-#define        TRUE    (1)
-#define        FALSE   (0)
+#ifndef lint
+static char sccsid[] = "@(#)ctags.c    8.2 (Berkeley) %G%";
+#endif /* not lint */
 
 
-#define        iswhite(arg)    (_wht[arg])     /* T if char is white           */
-#define        begtoken(arg)   (_btk[arg])     /* T if char can start token    */
-#define        intoken(arg)    (_itk[arg])     /* T if char can be in token    */
-#define        endtoken(arg)   (_etk[arg])     /* T if char ends tokens        */
-#define        isgood(arg)     (_gd[arg])      /* T if char can be after ')'   */
+#include <err.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
 
 
-#define        max(I1,I2)      (I1 > I2 ? I1 : I2)
+#include "ctags.h"
 
 
-struct nd_st {                 /* sorting structure                    */
-       char    *func;                  /* function name                */
-       char    *file;                  /* file name                    */
-       int     lno;                    /* for -x option                */
-       char    *pat;                   /* search pattern               */
-       logical been_warned;            /* set if noticed dup           */
-       struct  nd_st   *left,*right;   /* left and right sons          */
-};
+/*
+ * ctags: create a tags file
+ */
 
 
-long   ftell();
-typedef        struct  nd_st   NODE;
+NODE   *head;                  /* head of the sorted binary tree */
 
 
-logical        number,                         /* T if on line starting with # */
-       term    = FALSE,                /* T if print on terminal       */
-       makefile= TRUE,                 /* T if to creat "tags" file    */
-       gotone,                         /* found a func already on line */
-                                       /* boolean "func" (see init)    */
-       _wht[0177],_etk[0177],_itk[0177],_btk[0177],_gd[0177];
+                               /* boolean "func" (see init()) */
+bool   _wht[256], _etk[256], _itk[256], _btk[256], _gd[256];
 
 
-char   searchar = '?';                 /* use ?...? searches           */
+FILE   *inf;                   /* ioptr for current input file */
+FILE   *outf;                  /* ioptr for tags file */
 
 
-int    lineno;                         /* line number of current line */
-char   line[4*BUFSIZ],         /* current input line                   */
-       *curfile,               /* current input file name              */
-       *outfile= "tags",       /* output file                          */
-       *white  = " \f\t\n",    /* white chars                          */
-       *endtk  = " \t\n\"'#()[]{}=-+%*/&|^~!<>;,.:?",
-                               /* token ending chars                   */
-       *begtk  = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",
-                               /* token starting chars                 */
-       *intk   = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz0123456789",                            /* valid in-token chars                 */
-       *notgd  = ",;";         /* non-valid after-function chars       */
+long   lineftell;              /* ftell after getc( inf ) == '\n' */
 
 
-int    file_num;               /* current file number                  */
-int    aflag;                  /* -a: append to tags */
-int    uflag;                  /* -u: update tags */
+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    wflag;                  /* -w: suppress warnings */
-int    vflag;                  /* -v: create vgrind style index output */
-int    xflag;                  /* -x: create cxref style output */
-
-char   lbuf[BUFSIZ];
-
-FILE   *inf,                   /* ioptr for current input file         */
-       *outf;                  /* ioptr for tags file                  */
-
-long   lineftell;              /* ftell after getc( inf ) == '\n'      */
-
-NODE   *head;                  /* the head of the sorted binary tree   */
-
-char   *savestr();
-char   *rindex();
-main(ac,av)
-int    ac;
-char   *av[];
-{
-       char cmd[100];
-       int i;
-
-       while (ac > 1 && av[1][0] == '-') {
-               for (i=1; av[1][i]; i++) {
-                       switch(av[1][i]) {
-                               case 'a':
-                                       aflag++;
-                                       break;
-                               case 'u':
-                                       uflag++;
-                                       break;
-                               case 'w':
-                                       wflag++;
-                                       break;
-                               case 'v':
-                                       vflag++;
-                                       xflag++;
-                                       break;
-                               case 'x':
-                                       xflag++;
-                                       break;
-                               default:
-                                       goto usage;
-                       }
+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 *));
+
+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")) != EOF)
+               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:
+                       goto usage;
                }
                }
-               ac--; av++;
-       }
-
-       if (ac <= 1) {
-               usage: printf("Usage: ctags [-au] file ...\n");
+       argv += optind;
+       argc -= optind;
+       if (!argc) {
+usage:         (void)fprintf(stderr,
+                       "usage: ctags [-BFadtuwvx] [-f tagsfile] file ...");
                exit(1);
        }
 
                exit(1);
        }
 
-       init();                 /* set up boolean "functions"           */
-       /*
-        * loop through files finding functions
-        */
-       for (file_num = 1; file_num < ac; file_num++)
-               find_funcs(av[file_num]);
+       init();
 
 
-       if (xflag) {
-               put_funcs(head);
-               exit(0);
-       }
-       if (uflag) {
-               for (i=1; i<ac; i++) {
-                       sprintf(cmd,
-                               "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS",
-                               outfile, av[i], outfile);
-                       system(cmd);
+       for (exit_val = step = 0; step < argc; ++step)
+               if (!(inf = fopen(argv[step], "r"))) {
+                       warn("%s", argv[step]);
+                       exit_val = 1;
                }
                }
-               aflag++;
-       }
-       outf = fopen(outfile, aflag ? "a" : "w");
-       if (outf == NULL) {
-               perror(outfile);
-               exit(1);
-       }
-       put_funcs(head);
-       fclose(outf);
-       if (uflag) {
-               sprintf(cmd, "sort %s -o %s", outfile, outfile);
-               system(cmd);
-       }
-       exit(0);
-}
-
-/*
- * This routine sets up the boolean psuedo-functions which work
- * by seting boolean flags dependent upon the corresponding character
- * Every char which is NOT in that string is not a white char.  Therefore,
- * all of the array "_wht" is set to FALSE, and then the elements
- * subscripted by the chars in "white" are set to TRUE.  Thus "_wht"
- * of a char is TRUE if it is the string "white", else FALSE.
- */
-init()
-{
-
-       reg     char    *sp;
-       reg     int     i;
-
-       for (i = 0; i < 0177; i++) {
-               _wht[i] = _etk[i] = _itk[i] = _btk[i] = FALSE;
-               _gd[i] = TRUE;
-       }
-       for (sp = white; *sp; sp++)
-               _wht[*sp] = TRUE;
-       for (sp = endtk; *sp; sp++)
-               _etk[*sp] = TRUE;
-       for (sp = intk; *sp; sp++)
-               _itk[*sp] = TRUE;
-       for (sp = begtk; *sp; sp++)
-               _btk[*sp] = TRUE;
-       for (sp = notgd; *sp; sp++)
-               _gd[*sp] = FALSE;
-}
-
-/*
- * This routine opens the specified file and calls the function
- * which finds the function definitions.
- */
-find_funcs(file)
-char   *file;
-{
-       char *cp;
-
-       if ((inf=fopen(file,"r")) == NULL) {
-               perror(file);
-               return;
-       }
-       curfile = savestr(file);
-       cp = rindex(file, '.');
-       if (cp && (cp[1] != 'c' || cp[1] != 'h') && cp[2] == 0) {
-               if (PF_funcs(inf) == 0) {
-                       rewind(inf);
-                       C_funcs();
+               else {
+                       curfile = argv[step];
+                       find_entries(argv[step]);
+                       (void)fclose(inf);
                }
                }
-       } else
-               C_funcs();
-       fclose(inf);
-}
 
 
-pfnote(name, ln)
-       char *name;
-{
-       register char *fp;
-       register NODE *np;
-       char nbuf[BUFSIZ];
-
-       if ((np = (NODE *) malloc(sizeof (NODE))) == NULL) {
-               fprintf(stderr, "ctags: too many functions to sort\n");
-               put_funcs(head);
-               free_tree(head);
-               head = np = (NODE *) malloc(sizeof (NODE));
-       }
-       if (xflag == 0 && !strcmp(name, "main")) {
-               fp = rindex(curfile, '/');
-               if (fp == 0)
-                       fp = curfile;
-               else
-                       fp++;
-               sprintf(nbuf, "M%s", fp);
-               fp = rindex(nbuf, '.');
-               if (fp && fp[2] == 0)
-                       *fp = 0;
-               name = nbuf;
-       }
-       np->func = savestr(name);
-       np->file = curfile;
-       np->lno = ln;
-       np->left = np->right = 0;
-       if (xflag == 0) {
-               lbuf[50] = 0;
-               strcat(lbuf, "$");
-               lbuf[50] = 0;
-       }
-       np->pat = savestr(lbuf);
-       if (head == NULL)
-               head = np;
-       else
-               add_node(np, head);
-}
-
-/*
- * This routine finds functions in C syntax and adds them
- * to the list.
- */
-C_funcs()
-{
-       register int c;
-       register char *token, *tp;
-       int incomm, inquote, inchar, midtoken, level;
-       char *sp;
-       char tok[BUFSIZ];
-
-       lineno = 1;
-       number = gotone = midtoken = inquote = inchar = incomm = FALSE;
-       level = 0;
-       sp = tp = token = line;
-       for (;;) {
-               *sp=c=getc(inf);
-               if (feof(inf))
-                       break;
-               if (c == '\n')
-                       lineno++;
-               if (c == '\\') {
-                       c = *++sp = getc(inf);
-                       if (c = '\n')
-                               c = ' ';
-               } else if (incomm) {
-                       if (c == '*') {
-                               while ((*++sp=c=getc(inf)) == '*')
-                                       continue;
-                               if (c == '\n')
-                                       lineno++;
-                               if (c == '/')
-                                       incomm = FALSE;
+       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;
                        }
                        }
-               } else if (inquote) {
-                       /*
-                        * Too dumb to know about \" not being magic, but
-                        * they usually occur in pairs anyway.
-                        */
-                       if (c == '"')
-                               inquote = FALSE;
-                       continue;
-               } else if (inchar) {
-                       if (c == '\'')
-                               inchar = FALSE;
-                       continue;
-               } else switch (c) {
-               case '"':
-                       inquote = TRUE;
-                       continue;
-               case '\'':
-                       inchar = TRUE;
-                       continue;
-               case '/':
-                       if ((*++sp=c=getc(inf)) == '*')
-                               incomm = TRUE;
-                       else
-                               ungetc(*sp, inf);
-                       continue;
-               case '#':
-                       if (sp == line)
-                               number = TRUE;
-                       continue;
-               case '{':
-                       level++;
-                       continue;
-               case '}':
-                       if (sp == line)
-                               level = 0;      /* reset */
-                       else
-                               level--;
-                       continue;
-               }
-               if (!level && !inquote && !incomm && gotone == 0) {
-                       if (midtoken) {
-                               if (endtoken(c)) {
-                                       int pfline = lineno;
-                                       if (start_func(&sp,token,tp)) {
-                                               strncpy(tok,token,tp-token+1);
-                                               tok[tp-token+1] = 0;
-                                               getline();
-                                               pfnote(tok, pfline);
-                                               gotone = TRUE;
-                                       }
-                                       midtoken = FALSE;
-                                       token = sp;
-                               } else if (intoken(c))
-                                       tp++;
-                       } else if (begtoken(c)) {
-                               token = tp = sp;
-                               midtoken = TRUE;
+                       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);
                        }
                }
                        }
                }
-               sp++;
-               if (c == '\n' || sp > &line[sizeof (line) - BUFSIZ]) {
-                       tp = token = sp = line;
-                       lineftell = ftell(inf);
-                       number = gotone = midtoken = inquote = inchar = FALSE;
-               }
-       }
+       exit(exit_val);
 }
 
 /*
 }
 
 /*
- *     This routine  checks to see if the current token is
- * at the start of a function.  It updates the input line
- * so that the '(' will be in it when it returns.
+ * 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.
  */
  */
-start_func(lp,token,tp)
-char   **lp,*token,*tp;
+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;
+}
 
 
-       reg     char    c,*sp,*tsp;
-       static  logical found;
-       logical firsttok;               /* T if have seen first token in ()'s */
-       int     bad;
-
-       sp = *lp;
-       c = *sp;
-       bad = FALSE;
-       if (!number) {          /* space is not allowed in macro defs   */
-               while (iswhite(c)) {
-                       *++sp = c = getc(inf);
-                       if (c == '\n') {
-                               lineno++;
-                               if (sp > &line[sizeof (line) - BUFSIZ])
-                                       goto ret;
+/*
+ * 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;
+                               }
                        }
                        }
-               }
-       /* the following tries to make it so that a #define a b(c)      */
-       /* doesn't count as a define of b.                              */
-       } else {
-               logical define;
-
-               define = TRUE;
-               for (tsp = "define"; *tsp && token < tp; tsp++)
-                       if (*tsp != *token++) {
-                               define = FALSE;
-                               break;
+#define        LISPCHR ";(["
+/* lisp */             if (strchr(LISPCHR, c)) {
+                               l_entries();
+                               return;
                        }
                        }
-               if (define)
-                       found = 0;
-               else
-                       found++;
-               if (found >= 2) {
-                       gotone = TRUE;
-badone:                        bad = TRUE;
-                       goto ret;
-               }
-       }
-       if (c != '(')
-               goto badone;
-       firsttok = FALSE;
-       while ((*++sp=c=getc(inf)) != ')') {
-               if (c == '\n') {
-                       lineno++;
-                       if (sp > &line[sizeof (line) - BUFSIZ])
-                               goto ret;
-               }
-               /*
-                * This line used to confuse ctags:
-                *      int     (*oldhup)();
-                * This fixes it. A nonwhite char before the first
-                * token, other than a / (in case of a comment in there)
-                * makes this not a declaration.
-                */
-               if (begtoken(c) || c=='/') firsttok++;
-               else if (!iswhite(c) && !firsttok) goto badone;
-       }
-       while (iswhite(*++sp=c=getc(inf)))
-               if (c == '\n') {
-                       lineno++;
-                       if (sp > &line[sizeof (line) - BUFSIZ])
-                               break;
-               }
-ret:
-       *lp = --sp;
-       if (c == '\n')
-               lineno--;
-       ungetc(c,inf);
-       return !bad && isgood(c);
-}
-
-getline()
-{
-       long saveftell = ftell( inf );
-       register char *cp;
-
-       fseek( inf , lineftell , 0 );
-       fgets(lbuf, sizeof lbuf, inf);
-       cp = rindex(lbuf, '\n');
-       if (cp)
-               *cp = 0;
-       fseek(inf, saveftell, 0);
-}
-
-free_tree(node)
-NODE   *node;
-{
-
-       while (node) {
-               free_tree(node->right);
-               cfree(node);
-               node = node->left;
-       }
-}
-
-add_node(node, cur_node)
-       NODE *node,*cur_node;
-{
-       register int dif;
-
-       dif = strcmp(node->func,cur_node->func);
-       if (dif == 0) {
-               if (node->file == cur_node->file) {
-                       if (!wflag) {
-fprintf(stderr,"Duplicate function in file %s, line %d: %s\n",
-    node->file,lineno,node->func);
-fprintf(stderr,"Second entry ignored\n");
+/* 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);
                        }
                        }
-                       return;
                }
                }
-               if (!cur_node->been_warned)
-                       if (!wflag)
-fprintf(stderr,"Duplicate function in files %s and %s: %s (Warning only)\n",
-    node->file, cur_node->file, node->func);
-               cur_node->been_warned = TRUE;
-               return;
-       } 
-       if (dif < 0) {
-               if (cur_node->left != NULL)
-                       add_node(node,cur_node->left);
-               else
-                       cur_node->left = node;
-               return;
-       }
-       if (cur_node->right != NULL)
-               add_node(node,cur_node->right);
-       else
-               cur_node->right = node;
-}
-
-put_funcs(node)
-reg NODE       *node;
-{
-       reg char        *sp;
-
-       if (node == NULL)
-               return;
-       put_funcs(node->left);
-       if (xflag == 0) {
-               fprintf(outf, "%s\t%s\t%c^", node->func, node->file ,searchar);
-               for (sp = node->pat; *sp; sp++)
-                       if (*sp == '\\')
-                               fprintf(outf, "\\\\");
-                       else
-                               putc(*sp, outf);
-               fprintf(outf, "%c\n", searchar);
-       }
-       else if (vflag)
-               fprintf(stdout, "%s %s %d\n", node->func, node->file, (node->lno+63)/64);
-       else
-               fprintf(stdout, "%-16s%4d %-16s %s\n",
-                   node->func, node->lno, node->file, node->pat);
-       put_funcs(node->right);
-}
-
-char   *dbp = lbuf;
-int    pfcnt;
-
-PF_funcs(fi)
-       FILE *fi;
-{
-
-       lineno = 0;
-       pfcnt = 0;
-       while (fgets(lbuf, sizeof(lbuf), fi)) {
-               lineno++;
-               dbp = lbuf;
-               if ( *dbp == '%' ) dbp++ ;      /* Ratfor escape to fortran */
-               while (isspace(*dbp))
-                       dbp++;
-               if (*dbp == 0)
-                       continue;
-               switch (*dbp |' ') {
-
-               case 'i':
-                       if (tail("integer"))
-                               takeprec();
-                       break;
-               case 'r':
-                       if (tail("real"))
-                               takeprec();
-                       break;
-               case 'l':
-                       if (tail("logical"))
-                               takeprec();
-                       break;
-               case 'c':
-                       if (tail("complex") || tail("character"))
-                               takeprec();
-                       break;
-               case 'd':
-                       if (tail("double")) {
-                               while (isspace(*dbp))
-                                       dbp++;
-                               if (*dbp == 0)
-                                       continue;
-                               if (tail("precision"))
-                                       break;
-                               continue;
-                       }
-                       break;
+/* 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();
                }
                }
-               while (isspace(*dbp))
-                       dbp++;
-               if (*dbp == 0)
-                       continue;
-               switch (*dbp|' ') {
-
-               case 'f':
-                       if (tail("function"))
-                               getit();
-                       continue;
-               case 's':
-                       if (tail("subroutine"))
-                               getit();
-                       continue;
-               case 'p':
-                       if (tail("program")) {
-                               getit();
-                               continue;
-                       }
-                       if (tail("procedure"))
-                               getit();
-                       continue;
+/* fortran */  else if ((cp[1] != 'c' && cp[1] != 'h') && !cp[2]) {
+                       if (PF_funcs())
+                               return;
+                       rewind(inf);
                }
        }
                }
        }
-       return (pfcnt);
-}
-
-tail(cp)
-       char *cp;
-{
-       register int len = 0;
-
-       while (*cp && (*cp&~' ') == ((*(dbp+len))&~' '))
-               cp++, len++;
-       if (*cp == 0) {
-               dbp += len;
-               return (1);
-       }
-       return (0);
-}
-
-takeprec()
-{
-
-       while (isspace(*dbp))
-               dbp++;
-       if (*dbp != '*')
-               return;
-       dbp++;
-       while (isspace(*dbp))
-               dbp++;
-       if (!isdigit(*dbp)) {
-               --dbp;          /* force failure */
-               return;
-       }
-       do
-               dbp++;
-       while (isdigit(*dbp));
-}
-
-getit()
-{
-       register char *cp;
-       char c;
-       char nambuf[BUFSIZ];
-
-       for (cp = lbuf; *cp; cp++)
-               ;
-       *--cp = 0;      /* zap newline */
-       while (isspace(*dbp))
-               dbp++;
-       if (*dbp == 0 || !isalpha(*dbp))
-               return;
-       for (cp = dbp+1; *cp && (isalpha(*cp) || isdigit(*cp)); cp++)
-               continue;
-       c = cp[0];
-       cp[0] = 0;
-       strcpy(nambuf, dbp);
-       cp[0] = c;
-       pfnote(nambuf, lineno);
-       pfcnt++;
-}
-
-char *
-savestr(cp)
-       char *cp;
-{
-       register int len;
-       register char *dp;
-
-       len = strlen(cp);
-       dp = (char *)malloc(len+1);
-       strcpy(dp, cp);
-       return (dp);
-}
-
-/*
- * Return the ptr in sp at which the character c last
- * appears; NULL if not found
- *
- * Identical to v7 rindex, included for portability.
- */
-
-char *
-rindex(sp, c)
-register char *sp, c;
-{
-       register char *r;
-
-       r = NULL;
-       do {
-               if (*sp == c)
-                       r = sp;
-       } while (*sp++);
-       return(r);
+/* C */        c_entries();
 }
 }