* Francesco Potortì <pot@gnu.org> has maintained it since 1993.
*/
-char pot_etags_version[] = "@(#) pot revision number is 16.4";
+char pot_etags_version[] = "@(#) pot revision number is 16.10";
#define TRUE 1
#define FALSE 0
static language *get_language_from_langname __P((const char *));
static language *get_language_from_interpreter __P((char *));
static language *get_language_from_filename __P((char *, bool));
-static long readline __P((linebuffer *, FILE *));
+static void readline __P((linebuffer *, FILE *));
static long readline_internal __P((linebuffer *, FILE *));
static bool nocase_tail __P((char *));
static char *get_tag __P((char *));
Absolute names are stored in the output file as they are.\n\
Relative ones are stored relative to the output file's directory.\n");
- puts ("--parse-stdin=NAME\n\
- Read from standard input and record tags as belonging to file NAME.");
-
if (!CTAGS)
puts ("-a, --append\n\
Append tag entries to existing tags file.");
puts ("-R, --no-regex\n\
Don't create tags from regexps for the following files.");
#endif /* ETAGS_REGEXPS */
- puts ("-o FILE, --output=FILE\n\
- Write the tags to FILE.");
puts ("-I, --ignore-indentation\n\
Don't rely on indentation quite as much as normal. Currently,\n\
this means not to assume that a closing brace in the first\n\
column is the final brace of a function or structure\n\
definition in C and C++.");
+ puts ("-o FILE, --output=FILE\n\
+ Write the tags to FILE.");
+ puts ("--parse-stdin=NAME\n\
+ Read from standard input and record tags as belonging to file NAME.");
if (CTAGS)
{
argbuffer[current_arg].what = optarg;
++current_arg;
++file_count;
+ if (parsing_stdin)
+ fatal ("cannot parse standard input more than once", (char *)NULL);
parsing_stdin = TRUE;
break;
/* We rewind here, even if inf may be a pipe. We fail if the
length of the first line is longer than the pipe block size,
which is unlikely. */
- if (parser == NULL)
rewind (inf);
/* Else try to guess the language given the case insensitive file name. */
if (parser != NULL)
{
+ /* Generic initialisations before reading from file. */
+ lineno = 0; /* reset global line number */
+ charno = 0; /* reset global char number */
+ linecharno = 0; /* reset global char number of line start */
+
parser (inf);
return;
}
/* Else try Fortran. */
old_last_node = last_node;
curfdp->lang = get_language_from_langname ("fortran");
- Fortran_functions (inf);
+ find_entries (inf);
if (old_last_node == last_node)
/* No Fortran entries found. Try C. */
Only the file name will be recorded in the tags file. */
rewind (inf);
curfdp->lang = get_language_from_langname (cplusplus ? "c++" : "c");
- default_C_entries (inf);
+ find_entries (inf);
}
return;
}
#define CNL_SAVE_DEFINEDEF() \
do { \
curlinepos = charno; \
- lineno++; \
- linecharno = charno; \
- charno += readline (&curlb, inf); \
+ readline (&curlb, inf); \
lp = curlb.buffer; \
quotednl = FALSE; \
newndx = curndx; \
tokoff = toklen = typdefcblev = 0; /* keep compiler quiet */
curndx = newndx = 0;
- lineno = 0;
- charno = 0;
lp = curlb.buffer;
*lp = 0;
\f
/* Useful macros. */
#define LOOP_ON_INPUT_LINES(file_pointer, line_buffer, char_pointer) \
- for (lineno = charno = 0; /* loop initialization */ \
+ for (; /* loop initialization */ \
!feof (file_pointer) /* loop test */ \
- && (lineno++, /* instructions at start of loop */ \
- linecharno = charno, \
- charno += readline (&line_buffer, file_pointer), \
- char_pointer = lb.buffer, \
+ && (char_pointer = lb.buffer, /* instructions at start of loop */ \
+ readline (&line_buffer, file_pointer), \
TRUE); \
)
#define LOOKING_AT(cp, keyword) /* keyword is a constant string */ \
dbp = skip_spaces (dbp);
if (*dbp == '\0')
{
- lineno++;
- linecharno = charno;
- charno += readline (&lb, inf);
+ readline (&lb, inf);
dbp = lb.buffer;
if (dbp[5] != '&')
return;
if (*dbp == '\0'
|| (dbp[0] == '-' && dbp[1] == '-'))
{
- lineno++;
- linecharno = charno;
- charno += readline (&lb, inf);
+ readline (&lb, inf);
dbp = lb.buffer;
}
switch (lowcase(*dbp))
save_lcno = save_lineno = save_len = 0; /* keep compiler quiet */
namebuf = NULL; /* keep compiler quiet */
- lineno = 0;
- charno = 0;
dbp = lb.buffer;
*dbp = '\0';
initbuffer (&tline);
c = *dbp++;
if (c == '\0') /* if end of line */
{
- lineno++;
- linecharno = charno;
- charno += readline (&lb, inf);
+ readline (&lb, inf);
dbp = lb.buffer;
if (*dbp == '\0')
continue;
for (cp = plb->buffer; *cp != '\0'; cp++)
if (cp[0] == '*' && cp[1] == '/')
return;
- lineno++;
- linecharno += readline (plb, inf);
+ readline (plb, inf);
}
while (!feof(inf));
}
/* Take a string like "/blah/" and turn it into "blah", making sure
that the first and last characters are the same, and handling
quoted separator characters. Actually, stops on the occurrence of
- an unquoted separator. Also turns "\t" into a Tab character.
+ an unquoted separator. Also turns "\t" into a Tab character, and
+ similarly for all character escape sequences supported by Gcc.
Returns pointer to terminating separator. Works in place. Null
terminates name string. */
static char *
{
if (quoted)
{
- if (*name == 't')
- *copyto++ = '\t';
- else if (*name == sep)
- *copyto++ = sep;
- else
+ switch (*name)
{
- /* Something else is quoted, so preserve the quote. */
- *copyto++ = '\\';
- *copyto++ = *name;
+ case 'a': *copyto++ = '\007'; break;
+ case 'b': *copyto++ = '\b'; break;
+ case 'd': *copyto++ = 0177; break;
+ case 'e': *copyto++ = 033; break;
+ case 'f': *copyto++ = '\f'; break;
+ case 'n': *copyto++ = '\n'; break;
+ case 'r': *copyto++ = '\r'; break;
+ case 't': *copyto++ = '\t'; break;
+ case 'v': *copyto++ = '\v'; break;
+ default:
+ if (*name == sep)
+ *copyto++ = sep;
+ else
+ {
+ /* Something else is quoted, so preserve the quote. */
+ *copyto++ = '\\';
+ *copyto++ = *name;
+ }
+ break;
}
quoted = FALSE;
}
* Like readline_internal, above, but in addition try to match the
* input line against relevant regular expressions.
*/
-static long
+static void
readline (lbp, stream)
linebuffer *lbp;
FILE *stream;
{
- /* Read new line. */
- long result = readline_internal (lbp, stream);
+ long result;
+
+ linecharno = charno; /* update global char number of line start */
+ result = readline_internal (lbp, stream); /* read line */
+ lineno += 1; /* increment global line number */
+ charno += result; /* increment global char number */
/* Honour #line directives. */
if (!no_line_directive)
}
}
free (taggedabsname);
- lineno = lno;
- return readline (lbp, stream);
+ lineno = lno - 1;
+ readline (lbp, stream);
+ return;
} /* if a real #line directive */
} /* if #line is followed by a a number */
} /* if line begins with "#line " */
if (discard_until_line_directive)
{
if (result > 0)
+ {
/* Do a tail recursion on ourselves, thus discarding the contents
of the line buffer. */
- return readline (lbp, stream);
+ readline (lbp, stream);
+ return;
+ }
/* End of file. */
discard_until_line_directive = FALSE;
- return 0;
+ return;
}
} /* if #line directives should be considered */
}
}
#endif /* ETAGS_REGEXPS */
-
- return result;
}
\f