128 #define iswhite(arg) (_wht[arg]) 129 #define begtoken(arg) (_btk[arg]) 130 #define intoken(arg) (_itk[arg]) 131 #define endtoken(arg) (_etk[arg]) 132 #define isgood(arg) (_gd[arg]) 134 #define max(I1,I2) (I1 > I2 ? I1 : I2) 138 #define istoken(s, tok, len) (!strncmp(s,tok,len) && endtoken(*((s)+(len)))) 175 *
endtk =
" \t\n\"'#()[]{}=-+%*/&|^~!<>;,.:?",
177 *
begtk =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$",
179 *
intk =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789",
229 struct dsc$descriptor_s command =
231 strlen(buf), DSC$K_DTYPE_T, DSC$K_CLASS_S, buf
250 extern char *gfnames();
251 extern char *massage_name();
264 if (subname++ ==
NULL)
266 eflag = ! strcmp(subname,
"ctags");
271 while (ac > 1 && av[1][0] ==
'-')
273 for (i=1; av[1][i]; i++)
298 "%s: -f flag may only be given once\n",
progname);
302 if (ac <= 1 || av[1][0] ==
'\0')
305 "%s: -f flag must be followed by a filename\n",
344 fprintf (stderr,
"Usage: %s [-aetwvx] [-f outfile] file ...\n",
progname);
346 fprintf (stderr,
"Usage: %s [-BFaetuwvx] [-f outfile] file ...\n",
progname);
377 (this_file = gfnames (&ac, &av, &got_err)) !=
NULL;
file_num++)
381 error(
"Can't find file %s\n", this_file);
386 this_file = massage_name (this_file);
397 fprintf (
outf,
"\f\n%s,%d\n",
422 "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS",
431 fprintf (stderr,
"%s: ",
outfile);
461 for (i = 0; i < 0177; i++)
466 for (sp =
white; *sp; sp++)
468 for (sp =
endtk; *sp; sp++)
470 for (sp =
intk; *sp; sp++)
472 for (sp =
begtk; *sp; sp++)
474 for (sp =
notgd; *sp; sp++)
492 if ((
inf=fopen(file,
"r")) ==
NULL)
501 if (cp && (!strcmp (cp + 1,
"tex") || !strcmp (cp + 1,
"aux")
502 || !strcmp (cp + 1,
"bbl")))
509 if (cp && (!strcmp (cp + 1,
"l") ||
510 !strcmp (cp + 1,
"el") ||
511 !strcmp (cp + 1,
"lsp") ||
512 !strcmp (cp + 1,
"lisp") ||
513 !strcmp (cp + 1,
"cl") ||
514 !strcmp (cp + 1,
"clisp")))
521 if (cp && (!strcmp (cp + 1,
"sm")
522 || !strcmp (cp + 1,
"scm")
523 || !strcmp (cp + 1,
"scheme")
524 || !strcmp (cp + 1,
"t")
525 || !strcmp (cp + 1,
"sch")
526 || !strcmp (cp + 1,
"SM")
527 || !strcmp (cp + 1,
"SCM")
529 || (cp[-1] ==
'm' && cp[-2] ==
'c' && cp[-3] ==
's')
530 || (cp[-1] ==
'M' && cp[-2] ==
'C' && cp[-3] ==
'S')))
537 if (cp && (cp[1] !=
'c' && cp[1] !=
'h' && cp[1] !=
'y')
570 fprintf(stderr,
"%s: too many entries to sort\n",
progname);
577 if (!
eflag && !
xflag && !strcmp(name,
"main"))
584 altname =
concat (
"M", fp,
"");
585 fp =
rindex(altname,
'.');
586 if (fp && fp[2] == 0)
598 linestart[linelen] = 0;
602 sprintf (tem, strlen (linestart) < 50 ?
"%s$" :
"%.50s", linestart);
624 NODE *node,*cur_node;
628 dif = strcmp(node->name, cur_node->name);
634 if (node->file == cur_node->file)
638 fprintf(stderr,
"%s: Duplicate entry in file %s, line %d: %s\n",
640 fprintf(stderr,
"Second entry ignored\n");
644 if (!cur_node->been_warned)
646 fprintf(stderr,
"%s: Duplicate entry in files %s and %s: %s (Warning only)\n",
647 progname, node->file, cur_node->file, node->name);
648 cur_node->been_warned =
TRUE;
655 if (cur_node->left !=
NULL)
658 cur_node->left = node;
661 if (cur_node->right !=
NULL)
664 cur_node->right = node;
682 fprintf (
outf,
"%s%c%d,%d\n",
683 node->pat, 0177, node->lno, node->cno);
687 fprintf (
outf,
"%s\t%s\t",
688 node->name, node->file);
695 for (sp = node->pat; *sp; sp++)
705 fprintf (
outf,
"%d", node->lno);
710 fprintf (stdout,
"%s %s %d\n",
711 node->name, node->file, (node->lno+63)/64);
713 fprintf (stdout,
"%-16s%4d %-16s %s\n",
714 node->name, node->lno, node->file, node->pat);
741 total += strlen (node->pat) + 3;
766 #define VMS_SET_LINECHARNO (vmslinecharno = ftell(inf)) 768 #define VMS_SET_LINECHARNO 771 #define CNL_SAVE_NUMBER \ 773 VMS_SET_LINECHARNO; \ 774 linecharno = charno; lineno++; \ 775 charno += 1 + readline (&lb, inf); \ 788 register char *token, *tp, *lp;
789 logical incomm, inquote, inchar, midtoken;
799 gotone = midtoken = inquote = inchar = incomm =
FALSE;
821 while ((c = *lp++) ==
'*')
861 if (lp == lb.buffer + 1)
872 if (lp == lb.buffer + 1)
882 if (!level && !inquote && !incomm &&
gotone ==
FALSE)
889 char *
buf = lb.buffer;
890 int endpos = lp - lb.buffer;
895 long vmslinestart = vmslinecharno;
908 strncpy (tok, token + (
lb1.
buffer - buf),
915 strncpy (tok, token, tp-token+1);
917 pfnote(tok, f, lb.buffer, endpos, line, linestart);
950 static logical next_token_is_func;
975 if (
number >= 4 || (
number==2 && strncmp (token,
"define", 6)))
1016 if (!
number && !strncmp (token,
"DEF", 3))
1019 next_token_is_func = 1;
1022 if (next_token_is_func)
1024 next_token_is_func = 0;
1031 while ((c = *lp++) !=
')')
1046 if (
begtoken(c) || c==
'/') firsttok++;
1047 else if (!
iswhite(c) && !firsttok)
goto badone;
1069 fseek (
inf, atchar, 0);
1071 fseek (
inf, saveftell, 0);
1092 if (*dbp ==
'%') dbp++ ;
1093 while (isspace(*dbp))
1100 if (
tail(
"integer"))
1108 if (
tail(
"logical"))
1112 if (
tail(
"complex") ||
tail(
"character"))
1118 while (isspace(*dbp))
1122 if (
tail(
"precision"))
1128 while (isspace(*dbp))
1135 if (
tail(
"function"))
1139 if (
tail(
"subroutine"))
1143 if (
tail(
"program"))
1148 if (
tail(
"procedure"))
1159 register int len = 0;
1161 while (*cp && (*cp&~
' ') == ((*(dbp+len))&~
' '))
1173 while (isspace(*dbp))
1178 while (isspace(*dbp))
1187 while (isdigit(*dbp));
1194 char nambuf[BUFSIZ];
1196 while (isspace(*dbp))
1198 if (*dbp == 0 || !isalpha(*dbp))
1200 for (cp = dbp+1; *cp && (isalpha(*cp) || isdigit(*cp)); cp++)
1204 strcpy(nambuf, dbp);
1228 while (isspace(*dbp)) dbp++;
1229 if (dbp[0] ==
'(' &&
1230 (dbp[1] ==
'D' || dbp[1] ==
'd') &&
1231 (dbp[2] ==
'E' || dbp[2] ==
'e') &&
1232 (dbp[3] ==
'F' || dbp[3] ==
'f'))
1234 while (!isspace(*dbp)) dbp++;
1235 while (isspace(*dbp)) dbp++;
1238 if (dbp[0] ==
'(' &&
1241 while (!isspace(*dbp)) dbp++;
1242 while (isspace(*dbp)) dbp++;
1253 char nambuf[BUFSIZ];
1255 if (*dbp == 0)
return;
1256 for (cp = dbp+1; *cp && *cp !=
'(' && *cp !=
' '; cp++)
1260 strcpy(nambuf, dbp);
1288 if (dbp[0] ==
'(' &&
1289 (dbp[1] ==
'D' || dbp[1] ==
'd') &&
1290 (dbp[2] ==
'E' || dbp[2] ==
'e') &&
1291 (dbp[3] ==
'F' || dbp[3] ==
'f'))
1293 while (!isspace(*dbp)) dbp++;
1295 while (*dbp && (isspace(*dbp) || *dbp ==
'(')) dbp++;
1298 if (dbp[0] ==
'(' &&
1299 (dbp[1] ==
'S' || dbp[1] ==
's') &&
1300 (dbp[2] ==
'E' || dbp[2] ==
'e') &&
1301 (dbp[3] ==
'T' || dbp[3] ==
't') &&
1302 (dbp[4] ==
'!' || dbp[4] ==
'!') &&
1305 while (!isspace(*dbp)) dbp++;
1307 while (isspace(*dbp)) dbp++;
1318 char nambuf[BUFSIZ];
1320 if (*dbp == 0)
return;
1322 for (cp = dbp+1; *cp && *cp !=
'(' && *cp !=
')' && !isspace(*cp); cp++)
1328 strcpy(nambuf, dbp);
1353 ":chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem:typeout";
1396 while (dbp =
index (dbp, TEX_esc))
1415 #define TEX_LESC '\\' 1416 #define TEX_SESC '!' 1426 while ((c = getc (f)) != EOF)
1453 register char *env, *p;
1460 env = (
char *) getenv (evarname);
1464 env =
concat (env, defenv,
"");
1467 for (size = 1, p=env; p;)
1468 if ((p = index (p,
':')) && *(++p))
1476 p =
index (env,
':');
1478 p = env + strlen (env);
1482 tab[i].
len = strlen (tab[i].
name);
1505 char *p = name +
len;
1506 char nambuf[BUFSIZ];
1508 if (*name == 0)
return;
1511 while (*p && *p != TEX_clgrp)
1513 strncpy (nambuf, name, p - name);
1514 nambuf[p -
name] = 0;
1531 for (i = 0; TEX_toktab[i].
len > 0; i++)
1532 if (strncmp (TEX_toktab[i].
name, cp, TEX_toktab[i].
len) == 0)
1543 linebuffer->
size = 200;
1544 linebuffer->buffer = (
char *)
xmalloc (200);
1555 char *buffer = linebuffer->
buffer;
1556 register char *p = linebuffer->buffer;
1557 register char *pend = p + linebuffer->size;
1561 int c = getc (stream);
1564 linebuffer->size *= 2;
1565 buffer = (
char *)
xrealloc (buffer, linebuffer->size);
1566 p += buffer - linebuffer->buffer;
1567 pend = buffer + linebuffer->size;
1568 linebuffer->buffer = buffer;
1570 if (c < 0 || c ==
'\n')
1595 dp = (
char *)
xmalloc (len + 1);
1596 strncpy (dp, cp, len);
1632 register
char *sp, c;
1656 fprintf (stderr,
"%s: ",
progname);
1657 fprintf (stderr, s1, s2);
1658 fprintf (stderr,
"\n");
1667 int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
1668 char *result = (
char *)
xmalloc (len1 + len2 + len3 + 1);
1670 strcpy (result, s1);
1671 strcpy (result + len1, s2);
1672 strcpy (result + len1 + len2, s3);
1673 *(result + len1 + len2 + len3) = 0;
1684 int result = malloc (size);
1686 fatal (
"virtual memory exhausted", 0);
1695 int result = realloc (ptr, size);
1697 fatal (
"virtual memory exhausted");
static char buf[CHAR_SIZE]