34 |
* Francesco Potort́ <pot@gnu.org> has maintained it since 1993. |
* Francesco Potort́ <pot@gnu.org> has maintained it since 1993. |
35 |
*/ |
*/ |
36 |
|
|
37 |
char pot_etags_version[] = "@(#) pot revision number is 16.4"; |
char pot_etags_version[] = "@(#) pot revision number is 16.10"; |
38 |
|
|
39 |
#define TRUE 1 |
#define TRUE 1 |
40 |
#define FALSE 0 |
#define FALSE 0 |
349 |
static language *get_language_from_langname __P((const char *)); |
static language *get_language_from_langname __P((const char *)); |
350 |
static language *get_language_from_interpreter __P((char *)); |
static language *get_language_from_interpreter __P((char *)); |
351 |
static language *get_language_from_filename __P((char *, bool)); |
static language *get_language_from_filename __P((char *, bool)); |
352 |
static long readline __P((linebuffer *, FILE *)); |
static void readline __P((linebuffer *, FILE *)); |
353 |
static long readline_internal __P((linebuffer *, FILE *)); |
static long readline_internal __P((linebuffer *, FILE *)); |
354 |
static bool nocase_tail __P((char *)); |
static bool nocase_tail __P((char *)); |
355 |
static char *get_tag __P((char *)); |
static char *get_tag __P((char *)); |
711 |
Absolute names are stored in the output file as they are.\n\ |
Absolute names are stored in the output file as they are.\n\ |
712 |
Relative ones are stored relative to the output file's directory.\n"); |
Relative ones are stored relative to the output file's directory.\n"); |
713 |
|
|
|
puts ("--parse-stdin=NAME\n\ |
|
|
Read from standard input and record tags as belonging to file NAME."); |
|
|
|
|
714 |
if (!CTAGS) |
if (!CTAGS) |
715 |
puts ("-a, --append\n\ |
puts ("-a, --append\n\ |
716 |
Append tag entries to existing tags file."); |
Append tag entries to existing tags file."); |
781 |
puts ("-R, --no-regex\n\ |
puts ("-R, --no-regex\n\ |
782 |
Don't create tags from regexps for the following files."); |
Don't create tags from regexps for the following files."); |
783 |
#endif /* ETAGS_REGEXPS */ |
#endif /* ETAGS_REGEXPS */ |
|
puts ("-o FILE, --output=FILE\n\ |
|
|
Write the tags to FILE."); |
|
784 |
puts ("-I, --ignore-indentation\n\ |
puts ("-I, --ignore-indentation\n\ |
785 |
Don't rely on indentation quite as much as normal. Currently,\n\ |
Don't rely on indentation quite as much as normal. Currently,\n\ |
786 |
this means not to assume that a closing brace in the first\n\ |
this means not to assume that a closing brace in the first\n\ |
787 |
column is the final brace of a function or structure\n\ |
column is the final brace of a function or structure\n\ |
788 |
definition in C and C++."); |
definition in C and C++."); |
789 |
|
puts ("-o FILE, --output=FILE\n\ |
790 |
|
Write the tags to FILE."); |
791 |
|
puts ("--parse-stdin=NAME\n\ |
792 |
|
Read from standard input and record tags as belonging to file NAME."); |
793 |
|
|
794 |
if (CTAGS) |
if (CTAGS) |
795 |
{ |
{ |
1048 |
argbuffer[current_arg].what = optarg; |
argbuffer[current_arg].what = optarg; |
1049 |
++current_arg; |
++current_arg; |
1050 |
++file_count; |
++file_count; |
1051 |
|
if (parsing_stdin) |
1052 |
|
fatal ("cannot parse standard input more than once", (char *)NULL); |
1053 |
parsing_stdin = TRUE; |
parsing_stdin = TRUE; |
1054 |
break; |
break; |
1055 |
|
|
1703 |
/* We rewind here, even if inf may be a pipe. We fail if the |
/* We rewind here, even if inf may be a pipe. We fail if the |
1704 |
length of the first line is longer than the pipe block size, |
length of the first line is longer than the pipe block size, |
1705 |
which is unlikely. */ |
which is unlikely. */ |
|
if (parser == NULL) |
|
1706 |
rewind (inf); |
rewind (inf); |
1707 |
|
|
1708 |
/* Else try to guess the language given the case insensitive file name. */ |
/* Else try to guess the language given the case insensitive file name. */ |
1750 |
|
|
1751 |
if (parser != NULL) |
if (parser != NULL) |
1752 |
{ |
{ |
1753 |
|
/* Generic initialisations before reading from file. */ |
1754 |
|
lineno = 0; /* reset global line number */ |
1755 |
|
charno = 0; /* reset global char number */ |
1756 |
|
linecharno = 0; /* reset global char number of line start */ |
1757 |
|
|
1758 |
parser (inf); |
parser (inf); |
1759 |
return; |
return; |
1760 |
} |
} |
1762 |
/* Else try Fortran. */ |
/* Else try Fortran. */ |
1763 |
old_last_node = last_node; |
old_last_node = last_node; |
1764 |
curfdp->lang = get_language_from_langname ("fortran"); |
curfdp->lang = get_language_from_langname ("fortran"); |
1765 |
Fortran_functions (inf); |
find_entries (inf); |
1766 |
|
|
1767 |
if (old_last_node == last_node) |
if (old_last_node == last_node) |
1768 |
/* No Fortran entries found. Try C. */ |
/* No Fortran entries found. Try C. */ |
1771 |
Only the file name will be recorded in the tags file. */ |
Only the file name will be recorded in the tags file. */ |
1772 |
rewind (inf); |
rewind (inf); |
1773 |
curfdp->lang = get_language_from_langname (cplusplus ? "c++" : "c"); |
curfdp->lang = get_language_from_langname (cplusplus ? "c++" : "c"); |
1774 |
default_C_entries (inf); |
find_entries (inf); |
1775 |
} |
} |
1776 |
return; |
return; |
1777 |
} |
} |
2956 |
#define CNL_SAVE_DEFINEDEF() \ |
#define CNL_SAVE_DEFINEDEF() \ |
2957 |
do { \ |
do { \ |
2958 |
curlinepos = charno; \ |
curlinepos = charno; \ |
2959 |
lineno++; \ |
readline (&curlb, inf); \ |
|
linecharno = charno; \ |
|
|
charno += readline (&curlb, inf); \ |
|
2960 |
lp = curlb.buffer; \ |
lp = curlb.buffer; \ |
2961 |
quotednl = FALSE; \ |
quotednl = FALSE; \ |
2962 |
newndx = curndx; \ |
newndx = curndx; \ |
3048 |
|
|
3049 |
tokoff = toklen = typdefcblev = 0; /* keep compiler quiet */ |
tokoff = toklen = typdefcblev = 0; /* keep compiler quiet */ |
3050 |
curndx = newndx = 0; |
curndx = newndx = 0; |
|
lineno = 0; |
|
|
charno = 0; |
|
3051 |
lp = curlb.buffer; |
lp = curlb.buffer; |
3052 |
*lp = 0; |
*lp = 0; |
3053 |
|
|
3829 |
|
|
3830 |
/* Useful macros. */ |
/* Useful macros. */ |
3831 |
#define LOOP_ON_INPUT_LINES(file_pointer, line_buffer, char_pointer) \ |
#define LOOP_ON_INPUT_LINES(file_pointer, line_buffer, char_pointer) \ |
3832 |
for (lineno = charno = 0; /* loop initialization */ \ |
for (; /* loop initialization */ \ |
3833 |
!feof (file_pointer) /* loop test */ \ |
!feof (file_pointer) /* loop test */ \ |
3834 |
&& (lineno++, /* instructions at start of loop */ \ |
&& (char_pointer = lb.buffer, /* instructions at start of loop */ \ |
3835 |
linecharno = charno, \ |
readline (&line_buffer, file_pointer), \ |
|
charno += readline (&line_buffer, file_pointer), \ |
|
|
char_pointer = lb.buffer, \ |
|
3836 |
TRUE); \ |
TRUE); \ |
3837 |
) |
) |
3838 |
#define LOOKING_AT(cp, keyword) /* keyword is a constant string */ \ |
#define LOOKING_AT(cp, keyword) /* keyword is a constant string */ \ |
3892 |
dbp = skip_spaces (dbp); |
dbp = skip_spaces (dbp); |
3893 |
if (*dbp == '\0') |
if (*dbp == '\0') |
3894 |
{ |
{ |
3895 |
lineno++; |
readline (&lb, inf); |
|
linecharno = charno; |
|
|
charno += readline (&lb, inf); |
|
3896 |
dbp = lb.buffer; |
dbp = lb.buffer; |
3897 |
if (dbp[5] != '&') |
if (dbp[5] != '&') |
3898 |
return; |
return; |
4007 |
if (*dbp == '\0' |
if (*dbp == '\0' |
4008 |
|| (dbp[0] == '-' && dbp[1] == '-')) |
|| (dbp[0] == '-' && dbp[1] == '-')) |
4009 |
{ |
{ |
4010 |
lineno++; |
readline (&lb, inf); |
|
linecharno = charno; |
|
|
charno += readline (&lb, inf); |
|
4011 |
dbp = lb.buffer; |
dbp = lb.buffer; |
4012 |
} |
} |
4013 |
switch (lowcase(*dbp)) |
switch (lowcase(*dbp)) |
4451 |
|
|
4452 |
save_lcno = save_lineno = save_len = 0; /* keep compiler quiet */ |
save_lcno = save_lineno = save_len = 0; /* keep compiler quiet */ |
4453 |
namebuf = NULL; /* keep compiler quiet */ |
namebuf = NULL; /* keep compiler quiet */ |
|
lineno = 0; |
|
|
charno = 0; |
|
4454 |
dbp = lb.buffer; |
dbp = lb.buffer; |
4455 |
*dbp = '\0'; |
*dbp = '\0'; |
4456 |
initbuffer (&tline); |
initbuffer (&tline); |
4467 |
c = *dbp++; |
c = *dbp++; |
4468 |
if (c == '\0') /* if end of line */ |
if (c == '\0') /* if end of line */ |
4469 |
{ |
{ |
4470 |
lineno++; |
readline (&lb, inf); |
|
linecharno = charno; |
|
|
charno += readline (&lb, inf); |
|
4471 |
dbp = lb.buffer; |
dbp = lb.buffer; |
4472 |
if (*dbp == '\0') |
if (*dbp == '\0') |
4473 |
continue; |
continue; |
4978 |
for (cp = plb->buffer; *cp != '\0'; cp++) |
for (cp = plb->buffer; *cp != '\0'; cp++) |
4979 |
if (cp[0] == '*' && cp[1] == '/') |
if (cp[0] == '*' && cp[1] == '/') |
4980 |
return; |
return; |
4981 |
lineno++; |
readline (plb, inf); |
|
linecharno += readline (plb, inf); |
|
4982 |
} |
} |
4983 |
while (!feof(inf)); |
while (!feof(inf)); |
4984 |
} |
} |
5270 |
/* Take a string like "/blah/" and turn it into "blah", making sure |
/* Take a string like "/blah/" and turn it into "blah", making sure |
5271 |
that the first and last characters are the same, and handling |
that the first and last characters are the same, and handling |
5272 |
quoted separator characters. Actually, stops on the occurrence of |
quoted separator characters. Actually, stops on the occurrence of |
5273 |
an unquoted separator. Also turns "\t" into a Tab character. |
an unquoted separator. Also turns "\t" into a Tab character, and |
5274 |
|
similarly for all character escape sequences supported by Gcc. |
5275 |
Returns pointer to terminating separator. Works in place. Null |
Returns pointer to terminating separator. Works in place. Null |
5276 |
terminates name string. */ |
terminates name string. */ |
5277 |
static char * |
static char * |
5286 |
{ |
{ |
5287 |
if (quoted) |
if (quoted) |
5288 |
{ |
{ |
5289 |
if (*name == 't') |
switch (*name) |
|
*copyto++ = '\t'; |
|
|
else if (*name == sep) |
|
|
*copyto++ = sep; |
|
|
else |
|
5290 |
{ |
{ |
5291 |
/* Something else is quoted, so preserve the quote. */ |
case 'a': *copyto++ = '\007'; break; |
5292 |
*copyto++ = '\\'; |
case 'b': *copyto++ = '\b'; break; |
5293 |
*copyto++ = *name; |
case 'd': *copyto++ = 0177; break; |
5294 |
|
case 'e': *copyto++ = 033; break; |
5295 |
|
case 'f': *copyto++ = '\f'; break; |
5296 |
|
case 'n': *copyto++ = '\n'; break; |
5297 |
|
case 'r': *copyto++ = '\r'; break; |
5298 |
|
case 't': *copyto++ = '\t'; break; |
5299 |
|
case 'v': *copyto++ = '\v'; break; |
5300 |
|
default: |
5301 |
|
if (*name == sep) |
5302 |
|
*copyto++ = sep; |
5303 |
|
else |
5304 |
|
{ |
5305 |
|
/* Something else is quoted, so preserve the quote. */ |
5306 |
|
*copyto++ = '\\'; |
5307 |
|
*copyto++ = *name; |
5308 |
|
} |
5309 |
|
break; |
5310 |
} |
} |
5311 |
quoted = FALSE; |
quoted = FALSE; |
5312 |
} |
} |
5633 |
* Like readline_internal, above, but in addition try to match the |
* Like readline_internal, above, but in addition try to match the |
5634 |
* input line against relevant regular expressions. |
* input line against relevant regular expressions. |
5635 |
*/ |
*/ |
5636 |
static long |
static void |
5637 |
readline (lbp, stream) |
readline (lbp, stream) |
5638 |
linebuffer *lbp; |
linebuffer *lbp; |
5639 |
FILE *stream; |
FILE *stream; |
5640 |
{ |
{ |
5641 |
/* Read new line. */ |
long result; |
5642 |
long result = readline_internal (lbp, stream); |
|
5643 |
|
linecharno = charno; /* update global char number of line start */ |
5644 |
|
result = readline_internal (lbp, stream); /* read line */ |
5645 |
|
lineno += 1; /* increment global line number */ |
5646 |
|
charno += result; /* increment global char number */ |
5647 |
|
|
5648 |
/* Honour #line directives. */ |
/* Honour #line directives. */ |
5649 |
if (!no_line_directive) |
if (!no_line_directive) |
5740 |
} |
} |
5741 |
} |
} |
5742 |
free (taggedabsname); |
free (taggedabsname); |
5743 |
lineno = lno; |
lineno = lno - 1; |
5744 |
return readline (lbp, stream); |
readline (lbp, stream); |
5745 |
|
return; |
5746 |
} /* if a real #line directive */ |
} /* if a real #line directive */ |
5747 |
} /* if #line is followed by a a number */ |
} /* if #line is followed by a a number */ |
5748 |
} /* if line begins with "#line " */ |
} /* if line begins with "#line " */ |
5751 |
if (discard_until_line_directive) |
if (discard_until_line_directive) |
5752 |
{ |
{ |
5753 |
if (result > 0) |
if (result > 0) |
5754 |
|
{ |
5755 |
/* Do a tail recursion on ourselves, thus discarding the contents |
/* Do a tail recursion on ourselves, thus discarding the contents |
5756 |
of the line buffer. */ |
of the line buffer. */ |
5757 |
return readline (lbp, stream); |
readline (lbp, stream); |
5758 |
|
return; |
5759 |
|
} |
5760 |
/* End of file. */ |
/* End of file. */ |
5761 |
discard_until_line_directive = FALSE; |
discard_until_line_directive = FALSE; |
5762 |
return 0; |
return; |
5763 |
} |
} |
5764 |
} /* if #line directives should be considered */ |
} /* if #line directives should be considered */ |
5765 |
|
|
5811 |
} |
} |
5812 |
} |
} |
5813 |
#endif /* ETAGS_REGEXPS */ |
#endif /* ETAGS_REGEXPS */ |
|
|
|
|
return result; |
|
5814 |
} |
} |
5815 |
|
|
5816 |
|
|