extern char *malloc (), *realloc ();
extern char *getenv ();
-extern char *index (), *rindex ();
extern char *strcpy (), *strncpy ();
extern int strcmp ();
-#ifdef hpux
-#define notdef
-#endif
+char *etags_index (), *etags_rindex ();
+char *savenstr ();
/* Define the symbol ETAGS to make the program "etags",
which makes emacs-style tag tables by default.
* for self-documentation only.
*/
#define LEVEL_OK_FOR_FUNCDEF() \
- (level==0 || c_ext && level==1 && structdef==sinbody)
+ (level==0 || (c_ext && level==1 && structdef==sinbody))
/*
* next_token_is_func
struct stat stat_buf;
stat (file, &stat_buf);
- if (!(stat_buf.st_mode & S_IFREG) || !(stat_buf.st_mode & S_IFLNK))
+ if (!(stat_buf.st_mode & S_IFREG)
+#ifdef S_IFLNK
+ || !(stat_buf.st_mode & S_IFLNK)
+#endif
+ )
{
fprintf (stderr, "Skipping %s: it is not a regular file.\n", file);
return;
}
if (emacs_tags_format)
{
- char *cp = rindex (file, '/');
+ char *cp = etags_rindex (file, '/');
if (cp)
++cp;
else
/*
* This routine sets up the boolean psuedo-functions which work
- * by seting boolean flags dependent upon the corresponding character
+ * by setting 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"
return;
}
curfile = savestr (file);
- cp = rindex (file, '.');
+ cp = etags_rindex (file, '.');
header_file = (cp && (streq (cp + 1, "h")));
PAS_funcs (inf);
goto close_and_return;
}
+ /* If .f or .for, assume it is fortran or nothing. */
+ if (cp && (streq (cp + 1, "f") || streq (cp + 1, "for")))
+ {
+ PF_funcs (inf);
+ goto close_and_return;
+ }
/* if not a .c or .h or .y file, try fortran */
- else if (cp && ((cp[1] != 'c'
- && cp[1] != 'h'
- && cp[1] != 'y')
- || (cp[1] != 0 && cp[2] != 0)))
+ if (cp && ((cp[1] != 'c'
+ && cp[1] != 'h'
+ && cp[1] != 'y')
+ || (cp[1] != 0 && cp[2] != 0)))
{
if (PF_funcs (inf) != 0)
goto close_and_return;
/* If ctags mode, change name "main" to M<thisfilename>. */
if (!emacs_tags_format && !cxref_style && streq (name, "main"))
{
- fp = rindex (curfile, '/');
+ fp = etags_rindex (curfile, '/');
name = concat ("M", fp == 0 ? curfile : fp + 1, "");
- fp = rindex (name, '.');
+ fp = etags_rindex (name, '.');
if (fp && fp[1] != '\0' && fp[2] == '\0')
*fp = 0;
rewritten = TRUE;
fprintf (stdout, "%s %s %d\n",
node->name, node->file, (node->lno + 63) / 64);
else
- fprintf (stdout, "%-16s%4d %-16s %s\n",
+ fprintf (stdout, "%-16s %3d %-16s %s\n",
node->name, node->lno, node->file, node->pat);
/* Output subentries that follow this one */
#define CNL_SAVE_DEFINEDEF \
{ \
+ quotednl = FALSE; \
prev_linepos = linepos; \
SET_FILEPOS (linepos, inf, charno); \
lineno++; \
int c_ext; /* extension of C? */
{
register int c; /* latest char read; '\0' for end of line */
- register int tokoff; /* offset in line of beginning of latest token */
+ register int tokoff; /* offset in line of start of latest token*/
register int toklen; /* length of latest token */
register char *lp; /* pointer one beyond the character `c' */
- logical incomm, inquote, inchar, midtoken;
+ logical incomm, inquote, inchar, quotednl, midtoken;
int level; /* current curly brace level */
char tokb[BUFSIZ];
*lp = 0;
definedef = dnone;
- gotone = midtoken = inquote = inchar = incomm = FALSE;
+ gotone = midtoken = inquote = inchar = incomm = quotednl = FALSE;
level = 0;
tydef = none;
next_token_is_func = 0;
'\0'; don't skip it, because it's the thing that tells us
to read the next line. */
if (*lp == 0)
- continue;
+ {
+ quotednl =TRUE;
+ continue;
+ }
lp++;
c = ' ';
}
{
if (c == '"')
inquote = FALSE;
- continue;
+ else if (c == '\\')
+ c = *lp++;
}
else if (inchar)
{
}
else if (c_ext && *lp == '/')
{
- c = 0; /* C++ comment: skip rest of line */
+ c = 0;
+ break;
}
continue;
case '#':
if (structdef == stagseen)
structdef = scolonseen;
break;
- /* Not a struct definition when semicolon seen in non-sinbody context. */
+ /* Not a struct definition when semicolon seen
+ in non-sinbody context. */
case ';':
if (structdef != snone && structdef != sinbody)
{
lp = lp_tmp;
if (bingo)
{
- if (GET_CHARNO (tok.linestart) != GET_CHARNO (linepos)
+ if (GET_CHARNO (tok.linestart) != GET_CHARNO(linepos)
&& !tok_at_end_of_line)
{
/*
tok.p = lb1.buffer + (tok.p - tok_linebuf);
tok_linebuf = lb1.buffer;
}
- if (structdef == sinbody && definedef == dnone && is_func)
+ if (structdef == sinbody
+ && definedef == dnone && is_func)
{ /* function defined in C++ class body */
sprintf (tokb, "%s::%.*s",
structtag[0] == '\0' ? "_anonymous_"
midtoken = TRUE;
}
}
- /* Detect end of line, after having handled the last token on the line. */
+ /* Detect end of line, having handled the last token on the line. */
if (c == 0)
{
- CNL;
+ if (incomm || inquote || quotednl)
+ {
+ CNL_SAVE_DEFINEDEF;
+ }
+ else
+ {
+ CNL;
+ }
gotone = FALSE;
}
if (c == ';' && tydef == end) /* clean with typedefs */
logical
consider_token (c, lpp, tokp, is_func, c_ext, level)
reg char c; /* IN: first char after the token */
- char **lpp; /* IN OUT: *lpp points to 2nd char after the token */
+ char **lpp; /* IN OUT: *lpp points
+ to 2nd char after the token */
reg TOKEN *tokp; /* IN */
logical *is_func; /* OUT */
int c_ext; /* IN */
{
case st_C_struct:
case st_C_enum:
- if (tydef == begin || (typedefs_and_cplusplus && level == 0 && structdef == snone))
+ if (tydef == begin
+ || (typedefs_and_cplusplus && level == 0 && structdef == snone))
{
structdef = skeyseen;
structkey = tokse;
structdef = snone;
(void) strcpy (structtag, "<error 3>");
}
- /* Now what? And how does/should this stuff interact with tydef?? */
- /* Also maybe reset lp to *lpp for benefit of the function finding code. */
+ /* Now what? And how does/should this stuff interact with tydef?? */
+ /* Also maybe reset lp to *lpp for sake of function-finding code. */
}
if (tydef == begin)
{
/* Detect GNUmacs's function-defining macros. */
if (definedef == dnone)
{
- if (strneq (tokp->p, "DEF", 3))
+ if (strneq (tokp->p, "DEF", 3)
+ || strneq (tokp->p, "ENTRY", 5)
+ || strneq (tokp->p, "SYSCALL", 7)
+ || strneq (tokp->p, "PSEUDO", 6))
{
next_token_is_func = TRUE;
goto badone;
if (tail ("subroutine"))
getit ();
continue;
+ case 'e':
+ if (tail ("entry"))
+ getit ();
+ continue;
case 'p':
if (tail ("program"))
{
while (isspace (*dbp))
dbp++;
- if (*dbp == 0 || (!isalpha (*dbp)) && (*dbp != '_') && (*dbp != '$'))
+ if (*dbp == 0
+ || (!isalpha (*dbp)
+ && *dbp != '_'
+ && *dbp != '$'))
return;
for (cp = dbp + 1; *cp && (isalpha (*cp) || isdigit (*cp)
|| (*cp == '_') || (*cp == '$')); cp++)
TEX_toktab = TEX_decode_env ("TEXTAGS", TEX_defenv);
while (!feof (fi))
- {
+ { /* Scan each line in file */
lineno++;
linecharno = charno;
charno += readline (&lb, fi);
dbp = lb.buffer;
lasthit = dbp;
+ while (dbp = etags_index (dbp, TEX_esc)) /* Look at each escape in line */
+ {
+ register int i;
- while (!feof (fi))
- { /* Scan each line in file */
- lineno++;
- linecharno = charno;
- charno += readline (&lb, fi);
- dbp = lb.buffer;
+ if (!*(++dbp))
+ break;
+ linecharno += dbp - lasthit;
lasthit = dbp;
- while (dbp = index (dbp, TEX_esc)) /* Look at each escape in line */
+ i = TEX_Token (lasthit);
+ if (0 <= i)
{
- register int i;
-
- if (!*(++dbp))
- break;
- linecharno += dbp - lasthit;
- lasthit = dbp;
- i = TEX_Token (lasthit);
- if (0 <= i)
- {
- TEX_getit (lasthit, TEX_toktab[i].len);
- break; /* We only save a line once */
- }
+ TEX_getit (lasthit, TEX_toktab[i].len);
+ break; /* We only save a line once */
}
}
}
char *defenv;
{
register char *env, *p;
- extern char *savenstr (), *index ();
struct TEX_tabent *tab;
int size, i;
/* Allocate a token table */
for (size = 1, p = env; p;)
- if ((p = index (p, ':')) && *(++p))
+ if ((p = etags_index (p, ':')) && *(++p))
size++;
- tab = xnew (size, struct TEX_tabent);
+ /* Add 1 to leave room for null terminator. */
+ tab = xnew (size + 1, struct TEX_tabent);
/* Unpack environment string into token table. Be careful about */
/* zero-length strings (leading ':', "::" and trailing ':') */
for (i = 0; *env;)
{
- p = index (env, ':');
+ p = etags_index (env, ':');
if (!p) /* End of environment string. */
p = env + strlen (env);
if (p - env > 0)
}
/* If the text at CP matches one of the tag-defining TeX command names,
- return the index of that command in TEX_toktab.
+ return the etags_index of that command in TEX_toktab.
Otherwise return -1. */
/* Keep the capital `T' in `Token' for dumb truncating compilers
char *sub;
char *s;
{
- while (*s && (s = index (s, *sub)))
+ while (*s && (s = etags_index (s, *sub)))
if (prestr (sub, s))
return (TRUE);
else
return dp;
}
-#ifdef notdef
/*
* Return the ptr in sp at which the character c last
* appears; NULL if not found
*/
char *
-rindex (sp, c)
+etags_rindex (sp, c)
register char *sp, c;
{
register char *r;
return (r);
}
+
/*
* Return the ptr in sp at which the character c first
* appears; NULL if not found
*/
char *
-index (sp, c)
+etags_index (sp, c)
register char *sp, c;
{
do
return (NULL);
}
-#endif /* notdef */
-
/* Print error message and exit. */
/* VARARGS1 */