41 |
* configuration file containing regexp definitions for etags. |
* configuration file containing regexp definitions for etags. |
42 |
*/ |
*/ |
43 |
|
|
44 |
char pot_etags_version[] = "@(#) pot revision number is 17.5"; |
char pot_etags_version[] = "@(#) pot revision number is 17.13"; |
45 |
|
|
46 |
#define TRUE 1 |
#define TRUE 1 |
47 |
#define FALSE 0 |
#define FALSE 0 |
343 |
static void Cplusplus_entries __P((FILE *)); |
static void Cplusplus_entries __P((FILE *)); |
344 |
static void Cstar_entries __P((FILE *)); |
static void Cstar_entries __P((FILE *)); |
345 |
static void Erlang_functions __P((FILE *)); |
static void Erlang_functions __P((FILE *)); |
346 |
|
static void Forth_words __P((FILE *)); |
347 |
static void Fortran_functions __P((FILE *)); |
static void Fortran_functions __P((FILE *)); |
348 |
static void HTML_labels __P((FILE *)); |
static void HTML_labels __P((FILE *)); |
349 |
static void Lisp_functions __P((FILE *)); |
static void Lisp_functions __P((FILE *)); |
490 |
#if LONG_OPTIONS |
#if LONG_OPTIONS |
491 |
static struct option longopts[] = |
static struct option longopts[] = |
492 |
{ |
{ |
493 |
|
{ "append", no_argument, NULL, 'a' }, |
494 |
{ "packages-only", no_argument, &packages_only, TRUE }, |
{ "packages-only", no_argument, &packages_only, TRUE }, |
495 |
{ "c++", no_argument, NULL, 'C' }, |
{ "c++", no_argument, NULL, 'C' }, |
496 |
{ "declarations", no_argument, &declarations, TRUE }, |
{ "declarations", no_argument, &declarations, TRUE }, |
510 |
{ "parse-stdin", required_argument, NULL, STDIN }, |
{ "parse-stdin", required_argument, NULL, STDIN }, |
511 |
{ "version", no_argument, NULL, 'V' }, |
{ "version", no_argument, NULL, 'V' }, |
512 |
|
|
513 |
#if CTAGS /* Etags options */ |
#if CTAGS /* Ctags options */ |
514 |
{ "backward-search", no_argument, NULL, 'B' }, |
{ "backward-search", no_argument, NULL, 'B' }, |
515 |
{ "cxref", no_argument, NULL, 'x' }, |
{ "cxref", no_argument, NULL, 'x' }, |
516 |
{ "defines", no_argument, NULL, 'd' }, |
{ "defines", no_argument, NULL, 'd' }, |
521 |
{ "vgrind", no_argument, NULL, 'v' }, |
{ "vgrind", no_argument, NULL, 'v' }, |
522 |
{ "no-warn", no_argument, NULL, 'w' }, |
{ "no-warn", no_argument, NULL, 'w' }, |
523 |
|
|
524 |
#else /* Ctags options */ |
#else /* Etags options */ |
|
{ "append", no_argument, NULL, 'a' }, |
|
525 |
{ "no-defines", no_argument, NULL, 'D' }, |
{ "no-defines", no_argument, NULL, 'D' }, |
526 |
{ "no-globals", no_argument, &globals, FALSE }, |
{ "no-globals", no_argument, &globals, FALSE }, |
527 |
{ "include", required_argument, NULL, 'i' }, |
{ "include", required_argument, NULL, 'i' }, |
632 |
"In Erlang code, the tags are the functions, records and macros\n\ |
"In Erlang code, the tags are the functions, records and macros\n\ |
633 |
defined in the file."; |
defined in the file."; |
634 |
|
|
635 |
|
char *Forth_suffixes [] = |
636 |
|
{ "fth", "tok", NULL }; |
637 |
|
static char Forth_help [] = |
638 |
|
"In Forth code, tags are words defined by `:',\n\ |
639 |
|
constant, code, create, defer, value, variable, buffer:, field."; |
640 |
|
|
641 |
static char *Fortran_suffixes [] = |
static char *Fortran_suffixes [] = |
642 |
{ "F", "f", "f90", "for", NULL }; |
{ "F", "f", "f90", "for", NULL }; |
643 |
static char Fortran_help [] = |
static char Fortran_help [] = |
785 |
{ "c*", no_lang_help, Cstar_entries, Cstar_suffixes }, |
{ "c*", no_lang_help, Cstar_entries, Cstar_suffixes }, |
786 |
{ "cobol", Cobol_help, Cobol_paragraphs, Cobol_suffixes }, |
{ "cobol", Cobol_help, Cobol_paragraphs, Cobol_suffixes }, |
787 |
{ "erlang", Erlang_help, Erlang_functions, Erlang_suffixes }, |
{ "erlang", Erlang_help, Erlang_functions, Erlang_suffixes }, |
788 |
|
{ "forth", Forth_help, Forth_words, Forth_suffixes }, |
789 |
{ "fortran", Fortran_help, Fortran_functions, Fortran_suffixes }, |
{ "fortran", Fortran_help, Fortran_functions, Fortran_suffixes }, |
790 |
{ "html", HTML_help, HTML_labels, HTML_suffixes }, |
{ "html", HTML_help, HTML_labels, HTML_suffixes }, |
791 |
{ "java", Cjava_help, Cjava_entries, Cjava_suffixes }, |
{ "java", Cjava_help, Cjava_entries, Cjava_suffixes }, |
889 |
Absolute names are stored in the output file as they are.\n\ |
Absolute names are stored in the output file as they are.\n\ |
890 |
Relative ones are stored relative to the output file's directory.\n"); |
Relative ones are stored relative to the output file's directory.\n"); |
891 |
|
|
892 |
if (!CTAGS) |
puts ("-a, --append\n\ |
|
puts ("-a, --append\n\ |
|
893 |
Append tag entries to existing tags file."); |
Append tag entries to existing tags file."); |
894 |
|
|
895 |
puts ("--packages-only\n\ |
puts ("--packages-only\n\ |
1187 |
globals = TRUE; |
globals = TRUE; |
1188 |
} |
} |
1189 |
|
|
1190 |
|
/* When the optstring begins with a '-' getopt_long does not rearrange the |
1191 |
|
non-options arguments to be at the end, but leaves them alone. */ |
1192 |
optstring = "-"; |
optstring = "-"; |
1193 |
#ifdef ETAGS_REGEXPS |
#ifdef ETAGS_REGEXPS |
1194 |
optstring = "-r:Rc:"; |
optstring = "-r:Rc:"; |
1195 |
#endif /* ETAGS_REGEXPS */ |
#endif /* ETAGS_REGEXPS */ |
1196 |
if (!LONG_OPTIONS) |
if (!LONG_OPTIONS) |
1197 |
optstring += 1; |
optstring += 1; /* remove the initial '-' */ |
1198 |
optstring = concat (optstring, |
optstring = concat (optstring, |
1199 |
"Cf:Il:o:SVhH", |
"aCf:Il:o:SVhH", |
1200 |
(CTAGS) ? "BxdtTuvw" : "aDi:"); |
(CTAGS) ? "BxdtTuvw" : "Di:"); |
1201 |
|
|
1202 |
while ((opt = getopt_long (argc, argv, optstring, longopts, 0)) != EOF) |
while ((opt = getopt_long (argc, argv, optstring, longopts, NULL)) != EOF) |
1203 |
switch (opt) |
switch (opt) |
1204 |
{ |
{ |
1205 |
case 0: |
case 0: |
1227 |
break; |
break; |
1228 |
|
|
1229 |
/* Common options. */ |
/* Common options. */ |
1230 |
|
case 'a': append_to_tagfile = TRUE; break; |
1231 |
case 'C': cplusplus = TRUE; break; |
case 'C': cplusplus = TRUE; break; |
1232 |
case 'f': /* for compatibility with old makefiles */ |
case 'f': /* for compatibility with old makefiles */ |
1233 |
case 'o': |
case 'o': |
1277 |
break; |
break; |
1278 |
|
|
1279 |
/* Etags options */ |
/* Etags options */ |
|
case 'a': append_to_tagfile = TRUE; break; |
|
1280 |
case 'D': constantypedefs = FALSE; break; |
case 'D': constantypedefs = FALSE; break; |
1281 |
case 'i': included_files[nincluded_files++] = optarg; break; |
case 'i': included_files[nincluded_files++] = optarg; break; |
1282 |
|
|
1294 |
/* NOTREACHED */ |
/* NOTREACHED */ |
1295 |
} |
} |
1296 |
|
|
1297 |
|
/* No more options. Store the rest of arguments. */ |
1298 |
for (; optind < argc; optind++) |
for (; optind < argc; optind++) |
1299 |
{ |
{ |
1300 |
argbuffer[current_arg].arg_type = at_filename; |
argbuffer[current_arg].arg_type = at_filename; |
1423 |
|
|
1424 |
if (!CTAGS || cxref_style) |
if (!CTAGS || cxref_style) |
1425 |
{ |
{ |
1426 |
put_entries (nodehead); /* write the remainig tags (ETAGS) */ |
put_entries (nodehead); /* write the remaining tags (ETAGS) */ |
1427 |
free_tree (nodehead); |
free_tree (nodehead); |
1428 |
nodehead = NULL; |
nodehead = NULL; |
1429 |
if (!CTAGS) |
if (!CTAGS) |
4085 |
char_pointer = line_buffer.buffer, \ |
char_pointer = line_buffer.buffer, \ |
4086 |
TRUE); \ |
TRUE); \ |
4087 |
) |
) |
4088 |
#define LOOKING_AT(cp, keyword) /* keyword is a constant string */ \ |
|
4089 |
(strneq ((cp), keyword, sizeof(keyword)-1) /* cp points at keyword */ \ |
#define LOOKING_AT(cp, kw) /* kw is the keyword, a literal string */ \ |
4090 |
&& notinname ((cp)[sizeof(keyword)-1]) /* end of keyword */ \ |
((assert("" kw), TRUE) /* syntax error if not a literal string */ \ |
4091 |
&& ((cp) = skip_spaces((cp)+sizeof(keyword)-1))) /* skip spaces */ |
&& strneq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \ |
4092 |
|
&& notinname ((cp)[sizeof(kw)-1]) /* end of kw */ \ |
4093 |
|
&& ((cp) = skip_spaces((cp)+sizeof(kw)-1))) /* skip spaces */ |
4094 |
|
|
4095 |
|
/* Similar to LOOKING_AT but does not use notinname, does not skip */ |
4096 |
|
#define LOOKING_AT_NOCASE(cp, kw) /* the keyword is a literal string */ \ |
4097 |
|
((assert("" kw), TRUE) /* syntax error if not a literal string */ \ |
4098 |
|
&& strncaseeq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \ |
4099 |
|
&& ((cp) += sizeof(kw)-1)) /* skip spaces */ |
4100 |
|
|
4101 |
/* |
/* |
4102 |
* Read a file, but do no processing. This is used to do regexp |
* Read a file, but do no processing. This is used to do regexp |
4974 |
|
|
4975 |
|
|
4976 |
/* |
/* |
4977 |
* Postscript tag functions |
* Postscript tags |
4978 |
* Just look for lines where the first character is '/' |
* Just look for lines where the first character is '/' |
4979 |
* Also look at "defineps" for PSWrap |
* Also look at "defineps" for PSWrap |
4980 |
* Ideas by: |
* Ideas by: |
5005 |
|
|
5006 |
|
|
5007 |
/* |
/* |
5008 |
|
* Forth tags |
5009 |
|
* Ignore anything after \ followed by space or in ( ) |
5010 |
|
* Look for words defined by : |
5011 |
|
* Look for constant, code, create, defer, value, and variable |
5012 |
|
* OBP extensions: Look for buffer:, field, |
5013 |
|
* Ideas by Eduardo Horvath <eeh@netbsd.org> (2004) |
5014 |
|
*/ |
5015 |
|
static void |
5016 |
|
Forth_words (inf) |
5017 |
|
FILE *inf; |
5018 |
|
{ |
5019 |
|
register char *bp; |
5020 |
|
|
5021 |
|
LOOP_ON_INPUT_LINES (inf, lb, bp) |
5022 |
|
while ((bp = skip_spaces (bp))[0] != '\0') |
5023 |
|
if (bp[0] == '\\' && iswhite(bp[1])) |
5024 |
|
break; /* read next line */ |
5025 |
|
else if (bp[0] == '(' && iswhite(bp[1])) |
5026 |
|
do /* skip to ) or eol */ |
5027 |
|
bp++; |
5028 |
|
while (*bp != ')' && *bp != '\0'); |
5029 |
|
else if ((bp[0] == ':' && iswhite(bp[1]) && bp++) |
5030 |
|
|| LOOKING_AT_NOCASE (bp, "constant") |
5031 |
|
|| LOOKING_AT_NOCASE (bp, "code") |
5032 |
|
|| LOOKING_AT_NOCASE (bp, "create") |
5033 |
|
|| LOOKING_AT_NOCASE (bp, "defer") |
5034 |
|
|| LOOKING_AT_NOCASE (bp, "value") |
5035 |
|
|| LOOKING_AT_NOCASE (bp, "variable") |
5036 |
|
|| LOOKING_AT_NOCASE (bp, "buffer:") |
5037 |
|
|| LOOKING_AT_NOCASE (bp, "field")) |
5038 |
|
get_tag (skip_spaces (bp), NULL); /* Yay! A definition! */ |
5039 |
|
else |
5040 |
|
bp = skip_non_spaces (bp); |
5041 |
|
} |
5042 |
|
|
5043 |
|
|
5044 |
|
/* |
5045 |
* Scheme tag functions |
* Scheme tag functions |
5046 |
* look for (def... xyzzy |
* look for (def... xyzzy |
5047 |
* (def... (xyzzy |
* (def... (xyzzy |
5049 |
* (set! xyzzy |
* (set! xyzzy |
5050 |
* Original code by Ken Haase (1985?) |
* Original code by Ken Haase (1985?) |
5051 |
*/ |
*/ |
|
|
|
5052 |
static void |
static void |
5053 |
Scheme_functions (inf) |
Scheme_functions (inf) |
5054 |
FILE *inf; |
FILE *inf; |
5267 |
} |
} |
5268 |
|
|
5269 |
|
|
|
/* Similar to LOOKING_AT but does not use notinname, does not skip */ |
|
|
#define LOOKING_AT_NOCASE(cp, kw) /* kw is a constant string */ \ |
|
|
(strncaseeq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \ |
|
|
&& ((cp) += sizeof(kw)-1)) /* skip spaces */ |
|
|
|
|
5270 |
/* |
/* |
5271 |
* HTML support. |
* HTML support. |
5272 |
* Contents of <title>, <h1>, <h2>, <h3> are tags. |
* Contents of <title>, <h1>, <h2>, <h3> are tags. |
5483 |
|| (s[pos] == '(' && (pos += 1)) |
|| (s[pos] == '(' && (pos += 1)) |
5484 |
|| (s[pos] == ':' && s[pos + 1] == '-' && (pos += 2))) |
|| (s[pos] == ':' && s[pos + 1] == '-' && (pos += 2))) |
5485 |
&& (last == NULL /* save only the first clause */ |
&& (last == NULL /* save only the first clause */ |
5486 |
|| len != strlen (last) |
|| len != (int)strlen (last) |
5487 |
|| !strneq (s, last, len))) |
|| !strneq (s, last, len))) |
5488 |
{ |
{ |
5489 |
make_tag (s, len, TRUE, s, pos, lineno, linecharno); |
make_tag (s, len, TRUE, s, pos, lineno, linecharno); |
6551 |
: *s1 - *s2); |
: *s1 - *s2); |
6552 |
} |
} |
6553 |
|
|
6554 |
/* Skip spaces, return new pointer. */ |
/* Skip spaces (end of string is not space), return new pointer. */ |
6555 |
static char * |
static char * |
6556 |
skip_spaces (cp) |
skip_spaces (cp) |
6557 |
char *cp; |
char *cp; |
6561 |
return cp; |
return cp; |
6562 |
} |
} |
6563 |
|
|
6564 |
/* Skip non spaces, return new pointer. */ |
/* Skip non spaces, except end of string, return new pointer. */ |
6565 |
static char * |
static char * |
6566 |
skip_non_spaces (cp) |
skip_non_spaces (cp) |
6567 |
char *cp; |
char *cp; |