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",
234 struct dsc$descriptor_s command =
236 strlen(buf), DSC$K_DTYPE_T, DSC$K_CLASS_S, buf
255 extern char *gfnames();
256 extern char *massage_name();
269 if (subname++ ==
NULL)
271 eflag = ! strcmp(subname,
"ctags");
276 while (ac > 1 && av[1][0] ==
'-')
278 for (i=1; av[1][i]; i++)
303 "%s: -f flag may only be given once\n",
progname);
307 if (ac <= 1 || av[1][0] ==
'\0')
310 "%s: -f flag must be followed by a filename\n",
349 fprintf (stderr,
"Usage: %s [-aetwvx] [-f outfile] file ...\n",
progname);
351 fprintf (stderr,
"Usage: %s [-BFaetuwvx] [-f outfile] file ...\n",
progname);
382 (this_file = gfnames (&ac, &av, &got_err)) !=
NULL;
file_num++)
386 error(
"Can't find file %s\n", this_file);
391 this_file = massage_name (this_file);
402 fprintf (
outf,
"\f\n%s,%d\n",
427 "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS",
436 fprintf (stderr,
"%s: ",
outfile);
467 for (i = 0; i < 0177; i++)
472 for (sp =
white; *sp; sp++)
474 for (sp =
endtk; *sp; sp++)
476 for (sp =
intk; *sp; sp++)
478 for (sp =
begtk; *sp; sp++)
480 for (sp =
notgd; *sp; sp++)
503 if ((
inf=fopen(file,
"r")) ==
NULL)
512 if (cp && (!strcmp (cp + 1,
"tex") || !strcmp (cp + 1,
"aux")
513 || !strcmp (cp + 1,
"bbl")))
520 if (cp && (!strcmp (cp + 1,
"l") ||
521 !strcmp (cp + 1,
"el") ||
522 !strcmp (cp + 1,
"lsp") ||
523 !strcmp (cp + 1,
"lisp") ||
524 !strcmp (cp + 1,
"cl") ||
525 !strcmp (cp + 1,
"clisp")))
532 if (cp && (!strcmp (cp + 1,
"sm")
533 || !strcmp (cp + 1,
"scm")
534 || !strcmp (cp + 1,
"scheme")
535 || !strcmp (cp + 1,
"t")
536 || !strcmp (cp + 1,
"sch")
537 || !strcmp (cp + 1,
"SM")
538 || !strcmp (cp + 1,
"SCM")
540 || (cp[-1] ==
'm' && cp[-2] ==
'c' && cp[-3] ==
's')
541 || (cp[-1] ==
'M' && cp[-2] ==
'C' && cp[-3] ==
'S')))
548 if (cp && (cp[1] !=
'c' && cp[1] !=
'h' && cp[1] !=
'y')
584 fprintf(stderr,
"%s: too many entries to sort\n",
progname);
591 if (!
eflag && !
xflag && !strcmp(name,
"main"))
598 altname =
concat (
"M", fp,
"");
599 fp =
rindex(altname,
'.');
600 if (fp && fp[2] == 0)
612 linestart[linelen] = 0;
616 sprintf (tem, strlen (linestart) < 50 ?
"%s$" :
"%.50s", linestart);
640 NODE *node,*cur_node;
644 dif = strcmp(node->name, cur_node->name);
650 if (node->file == cur_node->file)
654 fprintf(stderr,
"%s: Duplicate entry in file %s, line %d: %s\n",
656 fprintf(stderr,
"Second entry ignored\n");
660 if (!cur_node->been_warned)
662 fprintf(stderr,
"%s: Duplicate entry in files %s and %s: %s (Warning only)\n",
663 progname, node->file, cur_node->file, node->name);
664 cur_node->been_warned =
TRUE;
671 if (cur_node->left !=
NULL)
674 cur_node->left = node;
677 if (cur_node->right !=
NULL)
680 cur_node->right = node;
699 fprintf (
outf,
"%s%c%d,%d\n",
700 node->pat, 0177, node->lno, node->cno);
704 fprintf (
outf,
"%s\t%s\t",
705 node->name, node->file);
712 for (sp = node->pat; *sp; sp++)
722 fprintf (
outf,
"%d", node->lno);
727 fprintf (stdout,
"%s %s %d\n",
728 node->name, node->file, (node->lno+63)/64);
730 fprintf (stdout,
"%-16s%4d %-16s %s\n",
731 node->name, node->lno, node->file, node->pat);
759 total += strlen (node->pat) + 3;
784 #define VMS_SET_LINECHARNO (vmslinecharno = ftell(inf)) 786 #define VMS_SET_LINECHARNO 789 #define CNL_SAVE_NUMBER \ 791 VMS_SET_LINECHARNO; \ 792 linecharno = charno; lineno++; \ 793 charno += 1 + readline (&lb, inf); \ 808 register char *token, *tp, *lp;
809 logical incomm, inquote, inchar, midtoken;
819 gotone = midtoken = inquote = inchar = incomm =
FALSE;
841 while ((c = *lp++) ==
'*')
881 if (lp == lb.buffer + 1)
892 if (lp == lb.buffer + 1)
902 if (!level && !inquote && !incomm &&
gotone ==
FALSE)
909 char *
buf = lb.buffer;
910 int endpos = lp - lb.buffer;
915 long vmslinestart = vmslinecharno;
928 strncpy (tok, token + (
lb1.
buffer - buf),
935 strncpy (tok, token, tp-token+1);
937 pfnote(tok, f, lb.buffer, endpos, line, linestart);
971 static logical next_token_is_func;
996 if (
number >= 4 || (
number==2 && strncmp (token,
"define", 6)))
1037 if (!
number && !strncmp (token,
"DEF", 3))
1040 next_token_is_func = 1;
1043 if (next_token_is_func)
1045 next_token_is_func = 0;
1052 while ((c = *lp++) !=
')')
1067 if (
begtoken(c) || c==
'/') firsttok++;
1068 else if (!
iswhite(c) && !firsttok)
goto badone;
1091 fseek (
inf, atchar, 0);
1093 fseek (
inf, saveftell, 0);
1117 if (*dbp ==
'%') dbp++ ;
1118 while (isspace(*dbp))
1125 if (
tail(
"integer"))
1133 if (
tail(
"logical"))
1137 if (
tail(
"complex") ||
tail(
"character"))
1143 while (isspace(*dbp))
1147 if (
tail(
"precision"))
1153 while (isspace(*dbp))
1160 if (
tail(
"function"))
1164 if (
tail(
"subroutine"))
1168 if (
tail(
"program"))
1173 if (
tail(
"procedure"))
1184 register int len = 0;
1186 while (*cp && (*cp&~
' ') == ((*(dbp+len))&~
' '))
1199 while (isspace(*dbp))
1204 while (isspace(*dbp))
1213 while (isdigit(*dbp));
1221 char nambuf[BUFSIZ];
1223 while (isspace(*dbp))
1225 if (*dbp == 0 || !isalpha(*dbp))
1227 for (cp = dbp+1; *cp && (isalpha(*cp) || isdigit(*cp)); cp++)
1231 strcpy(nambuf, dbp);
1257 while (isspace(*dbp)) dbp++;
1258 if (dbp[0] ==
'(' &&
1259 (dbp[1] ==
'D' || dbp[1] ==
'd') &&
1260 (dbp[2] ==
'E' || dbp[2] ==
'e') &&
1261 (dbp[3] ==
'F' || dbp[3] ==
'f'))
1263 while (!isspace(*dbp)) dbp++;
1264 while (isspace(*dbp)) dbp++;
1267 if (dbp[0] ==
'(' &&
1270 while (!isspace(*dbp)) dbp++;
1271 while (isspace(*dbp)) dbp++;
1283 char nambuf[BUFSIZ];
1285 if (*dbp == 0)
return;
1286 for (cp = dbp+1; *cp && *cp !=
'(' && *cp !=
' '; cp++)
1290 strcpy(nambuf, dbp);
1319 if (dbp[0] ==
'(' &&
1320 (dbp[1] ==
'D' || dbp[1] ==
'd') &&
1321 (dbp[2] ==
'E' || dbp[2] ==
'e') &&
1322 (dbp[3] ==
'F' || dbp[3] ==
'f'))
1324 while (!isspace(*dbp)) dbp++;
1326 while (*dbp && (isspace(*dbp) || *dbp ==
'(')) dbp++;
1329 if (dbp[0] ==
'(' &&
1330 (dbp[1] ==
'S' || dbp[1] ==
's') &&
1331 (dbp[2] ==
'E' || dbp[2] ==
'e') &&
1332 (dbp[3] ==
'T' || dbp[3] ==
't') &&
1333 (dbp[4] ==
'!' || dbp[4] ==
'!') &&
1336 while (!isspace(*dbp)) dbp++;
1338 while (isspace(*dbp)) dbp++;
1350 char nambuf[BUFSIZ];
1352 if (*dbp == 0)
return;
1354 for (cp = dbp+1; *cp && *cp !=
'(' && *cp !=
')' && !isspace(*cp); cp++)
1360 strcpy(nambuf, dbp);
1385 ":chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem:typeout";
1431 while (dbp =
index (dbp, TEX_esc))
1450 #define TEX_LESC '\\' 1451 #define TEX_SESC '!' 1462 while ((c = getc (f)) != EOF)
1489 register char *env, *p;
1496 env = (
char *) getenv (evarname);
1500 env =
concat (env, defenv,
"");
1503 for (size = 1, p=env; p;)
1504 if ((p = index (p,
':')) && *(++p))
1512 p =
index (env,
':');
1514 p = env + strlen (env);
1518 tab[i].
len = strlen (tab[i].
name);
1542 char *p = name +
len;
1543 char nambuf[BUFSIZ];
1545 if (*name == 0)
return;
1548 while (*p && *p != TEX_clgrp)
1550 strncpy (nambuf, name, p - name);
1551 nambuf[p -
name] = 0;
1569 for (i = 0; TEX_toktab[i].
len > 0; i++)
1570 if (strncmp (TEX_toktab[i].
name, cp, TEX_toktab[i].
len) == 0)
1581 linebuffer->
size = 200;
1582 linebuffer->buffer = (
char *)
xmalloc (200);
1593 char *buffer = linebuffer->
buffer;
1594 register char *p = linebuffer->buffer;
1595 register char *pend = p + linebuffer->size;
1599 int c = getc (stream);
1602 linebuffer->size *= 2;
1603 buffer = (
char *)
xrealloc (buffer, linebuffer->size);
1604 p += buffer - linebuffer->buffer;
1605 pend = buffer + linebuffer->size;
1606 linebuffer->buffer = buffer;
1608 if (c < 0 || c ==
'\n')
1633 dp = (
char *)
xmalloc (len + 1);
1634 strncpy (dp, cp, len);
1670 register
char *sp, c;
1682 void error (
char *s1,
char *s2);
1697 fprintf (stderr,
"%s: ",
progname);
1698 fprintf (stderr, s1, s2);
1699 fprintf (stderr,
"\n");
1708 int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
1709 char *result = (
char *)
xmalloc (len1 + len2 + len3 + 1);
1711 strcpy (result, s1);
1712 strcpy (result + len1, s2);
1713 strcpy (result + len1 + len2, s3);
1714 *(result + len1 + len2 + len3) = 0;
1725 int result = malloc (size);
1727 fatal (
"virtual memory exhausted", 0);
1736 int result = realloc (ptr, size);
1738 fatal (
"virtual memory exhausted");
static char buf[CHAR_SIZE]