/* Tags file maker to go with GNU Emacs -*- coding: latin-1 -*-
- Copyright (C) 1984, 1987-1989, 1993-1995, 1998-2001, 2002
- Free Software Foundation, Inc. and Ken Arnold
+ Copyright (C) 1984, 1987, 1988, 1989, 1993, 1994, 1995,
+ 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+ 2005, 2006 Free Software Foundation, Inc. and Ken Arnold
This file is not considered part of GNU Emacs.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
/*
* Authors:
* configuration file containing regexp definitions for etags.
*/
-char pot_etags_version[] = "@(#) pot revision number is 17.5";
+char pot_etags_version[] = "@(#) pot revision number is 17.17";
#define TRUE 1
#define FALSE 0
static void Cplusplus_entries __P((FILE *));
static void Cstar_entries __P((FILE *));
static void Erlang_functions __P((FILE *));
+static void Forth_words __P((FILE *));
static void Fortran_functions __P((FILE *));
static void HTML_labels __P((FILE *));
static void Lisp_functions __P((FILE *));
static bool ignoreindent; /* -I: ignore indentation in C */
static bool packages_only; /* --packages-only: in Ada, only tag packages*/
+/* STDIN is defined in LynxOS system headers */
+#ifdef STDIN
+# undef STDIN
+#endif
+
#define STDIN 0x1001 /* returned by getopt_long on --parse-stdin */
static bool parsing_stdin; /* --parse-stdin used */
#if LONG_OPTIONS
static struct option longopts[] =
{
+ { "append", no_argument, NULL, 'a' },
{ "packages-only", no_argument, &packages_only, TRUE },
{ "c++", no_argument, NULL, 'C' },
{ "declarations", no_argument, &declarations, TRUE },
{ "parse-stdin", required_argument, NULL, STDIN },
{ "version", no_argument, NULL, 'V' },
-#if CTAGS /* Etags options */
+#if CTAGS /* Ctags options */
{ "backward-search", no_argument, NULL, 'B' },
{ "cxref", no_argument, NULL, 'x' },
{ "defines", no_argument, NULL, 'd' },
{ "vgrind", no_argument, NULL, 'v' },
{ "no-warn", no_argument, NULL, 'w' },
-#else /* Ctags options */
- { "append", no_argument, NULL, 'a' },
+#else /* Etags options */
{ "no-defines", no_argument, NULL, 'D' },
{ "no-globals", no_argument, &globals, FALSE },
{ "include", required_argument, NULL, 'i' },
"In Erlang code, the tags are the functions, records and macros\n\
defined in the file.";
+char *Forth_suffixes [] =
+ { "fth", "tok", NULL };
+static char Forth_help [] =
+"In Forth code, tags are words defined by `:',\n\
+constant, code, create, defer, value, variable, buffer:, field.";
+
static char *Fortran_suffixes [] =
{ "F", "f", "f90", "for", NULL };
static char Fortran_help [] =
{ "c*", no_lang_help, Cstar_entries, Cstar_suffixes },
{ "cobol", Cobol_help, Cobol_paragraphs, Cobol_suffixes },
{ "erlang", Erlang_help, Erlang_functions, Erlang_suffixes },
+ { "forth", Forth_help, Forth_words, Forth_suffixes },
{ "fortran", Fortran_help, Fortran_functions, Fortran_suffixes },
{ "html", HTML_help, HTML_labels, HTML_suffixes },
{ "java", Cjava_help, Cjava_entries, Cjava_suffixes },
print_version ()
{
printf ("%s (%s %s)\n", (CTAGS) ? "ctags" : "etags", EMACS_NAME, VERSION);
- puts ("Copyright (C) 2002 Free Software Foundation, Inc. and Ken Arnold");
+ puts ("Copyright (C) 2006 Free Software Foundation, Inc. and Ken Arnold");
puts ("This program is distributed under the same terms as Emacs");
exit (EXIT_SUCCESS);
Absolute names are stored in the output file as they are.\n\
Relative ones are stored relative to the output file's directory.\n");
- if (!CTAGS)
- puts ("-a, --append\n\
+ puts ("-a, --append\n\
Append tag entries to existing tags file.");
puts ("--packages-only\n\
if (CTAGS)
{
puts ("-v, --vgrind\n\
- Generates an index of items intended for human consumption,\n\
- similar to the output of vgrind. The index is sorted, and\n\
- gives the page number of each item.");
+ Print on the standard output an index of items intended for\n\
+ human consumption, similar to the output of vgrind. The index\n\
+ is sorted, and gives the page number of each item.");
puts ("-w, --no-warn\n\
Suppress warning messages about entries defined in multiple\n\
files.");
globals = TRUE;
}
+ /* When the optstring begins with a '-' getopt_long does not rearrange the
+ non-options arguments to be at the end, but leaves them alone. */
optstring = "-";
#ifdef ETAGS_REGEXPS
optstring = "-r:Rc:";
#endif /* ETAGS_REGEXPS */
- if (LONG_OPTIONS)
- optstring += 1;
+ if (!LONG_OPTIONS)
+ optstring += 1; /* remove the initial '-' */
optstring = concat (optstring,
- "Cf:Il:o:SVhH",
- (CTAGS) ? "BxdtTuvw" : "aDi:");
+ "aCf:Il:o:SVhH",
+ (CTAGS) ? "BxdtTuvw" : "Di:");
- while ((opt = getopt_long (argc, argv, optstring, longopts, 0)) != EOF)
+ while ((opt = getopt_long (argc, argv, optstring, longopts, NULL)) != EOF)
switch (opt)
{
case 0:
break;
/* Common options. */
+ case 'a': append_to_tagfile = TRUE; break;
case 'C': cplusplus = TRUE; break;
case 'f': /* for compatibility with old makefiles */
case 'o':
break;
/* Etags options */
- case 'a': append_to_tagfile = TRUE; break;
case 'D': constantypedefs = FALSE; break;
case 'i': included_files[nincluded_files++] = optarg; break;
/* NOTREACHED */
}
+ /* No more options. Store the rest of arguments. */
for (; optind < argc; optind++)
{
argbuffer[current_arg].arg_type = at_filename;
this_file = argbuffer[i].what;
process_file (stdin, this_file, lang);
break;
- case at_end:
- break;
}
}
if (!CTAGS || cxref_style)
{
- put_entries (nodehead); /* write the remainig tags (ETAGS) */
+ /* Write the remaining tags to tagf (ETAGS) or stdout (CXREF). */
+ put_entries (nodehead);
free_tree (nodehead);
nodehead = NULL;
if (!CTAGS)
while (nincluded_files-- > 0)
fprintf (tagf, "\f\n%s,include\n", *included_files++);
+
+ if (fclose (tagf) == EOF)
+ pfatal (tagfile);
}
- if (fclose (tagf) == EOF)
- pfatal (tagfile);
exit (EXIT_SUCCESS);
}
if (fclose (tagf) == EOF)
pfatal (tagfile);
- if (update)
- {
- char cmd[2*BUFSIZ+10];
- sprintf (cmd, "sort -o %.*s %.*s", BUFSIZ, tagfile, BUFSIZ, tagfile);
- exit (system (cmd));
- }
+ if (CTAGS)
+ if (append_to_tagfile || update)
+ {
+ char cmd[2*BUFSIZ+10];
+ sprintf (cmd, "sort -o %.*s %.*s", BUFSIZ, tagfile, BUFSIZ, tagfile);
+ exit (system (cmd));
+ }
return EXIT_SUCCESS;
}
case tkeyseen:
switch (toktype)
{
- default:
- break;
case st_none:
case st_C_class:
case st_C_struct:
case tend:
switch (toktype)
{
- default:
- break;
case st_C_class:
case st_C_struct:
case st_C_enum:
return FALSE;
}
return TRUE;
- default:
- break;
}
/*
fvdef = fvnone;
}
return FALSE;
- default:
- break;
}
if (structdef == skeyseen)
case st_C_objimpl:
objdef = oimplementation;
return FALSE;
- default:
- break;
}
break;
case oimplementation:
objdef = onone;
}
return FALSE;
- default:
- break;
}
/* A function, variable or enum constant? */
return FALSE;
}
break;
- default:
- break;
}
/* FALLTHRU */
case fvnameseen:
fvdef = fvnameseen; /* function or variable */
*is_func_or_var = TRUE;
return TRUE;
- default:
- break;
}
break;
- default:
- break;
}
return FALSE;
fvdef = fignore;
}
break;
- default:
- break;
}
if (structdef == stagseen && !cjava)
{
case dsharpseen:
savetoken = token;
break;
- default:
- break;
}
if (!yacc_rules || lp == newlb.buffer + 1)
{
linebuffer_setlen (&token_name, token_name.len + 1);
strcat (token_name.buffer, ":");
break;
- default:
- break;
}
if (structdef == stagseen)
{
make_C_tag (TRUE); /* an Objective C method */
objdef = oinbody;
break;
- default:
- break;
}
switch (fvdef)
{
fvdef = fvnone;
}
break;
- default:
- break;
}
break;
case '(':
case flistseen:
fvdef = finlist;
break;
- default:
- break;
}
parlev++;
break;
case finlist:
fvdef = flistseen;
break;
- default:
- break;
}
if (!instruct
&& (typdef == tend
bracelev = -1;
}
break;
- default:
- break;
}
switch (structdef)
{
structdef = snone;
make_C_tag (FALSE); /* a struct or enum */
break;
- default:
- break;
}
bracelev++;
break;
char_pointer = line_buffer.buffer, \
TRUE); \
)
-#define LOOKING_AT(cp, keyword) /* keyword is a constant string */ \
- (strneq ((cp), keyword, sizeof(keyword)-1) /* cp points at keyword */ \
- && notinname ((cp)[sizeof(keyword)-1]) /* end of keyword */ \
- && ((cp) = skip_spaces((cp)+sizeof(keyword)-1))) /* skip spaces */
+
+#define LOOKING_AT(cp, kw) /* kw is the keyword, a literal string */ \
+ ((assert("" kw), TRUE) /* syntax error if not a literal string */ \
+ && strneq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \
+ && notinname ((cp)[sizeof(kw)-1]) /* end of kw */ \
+ && ((cp) = skip_spaces((cp)+sizeof(kw)-1))) /* skip spaces */
+
+/* Similar to LOOKING_AT but does not use notinname, does not skip */
+#define LOOKING_AT_NOCASE(cp, kw) /* the keyword is a literal string */ \
+ ((assert("" kw), TRUE) /* syntax error if not a literal string */ \
+ && strncaseeq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \
+ && ((cp) += sizeof(kw)-1)) /* skip spaces */
/*
* Read a file, but do no processing. This is used to do regexp
lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
}
}
+ free (package);
}
\f
/*
- * Postscript tag functions
+ * Postscript tags
* Just look for lines where the first character is '/'
* Also look at "defineps" for PSWrap
* Ideas by:
}
}
+\f
+/*
+ * Forth tags
+ * Ignore anything after \ followed by space or in ( )
+ * Look for words defined by :
+ * Look for constant, code, create, defer, value, and variable
+ * OBP extensions: Look for buffer:, field,
+ * Ideas by Eduardo Horvath <eeh@netbsd.org> (2004)
+ */
+static void
+Forth_words (inf)
+ FILE *inf;
+{
+ register char *bp;
+
+ LOOP_ON_INPUT_LINES (inf, lb, bp)
+ while ((bp = skip_spaces (bp))[0] != '\0')
+ if (bp[0] == '\\' && iswhite(bp[1]))
+ break; /* read next line */
+ else if (bp[0] == '(' && iswhite(bp[1]))
+ do /* skip to ) or eol */
+ bp++;
+ while (*bp != ')' && *bp != '\0');
+ else if ((bp[0] == ':' && iswhite(bp[1]) && bp++)
+ || LOOKING_AT_NOCASE (bp, "constant")
+ || LOOKING_AT_NOCASE (bp, "code")
+ || LOOKING_AT_NOCASE (bp, "create")
+ || LOOKING_AT_NOCASE (bp, "defer")
+ || LOOKING_AT_NOCASE (bp, "value")
+ || LOOKING_AT_NOCASE (bp, "variable")
+ || LOOKING_AT_NOCASE (bp, "buffer:")
+ || LOOKING_AT_NOCASE (bp, "field"))
+ get_tag (skip_spaces (bp), NULL); /* Yay! A definition! */
+ else
+ bp = skip_non_spaces (bp);
+}
+
\f
/*
* Scheme tag functions
* (set! xyzzy
* Original code by Ken Haase (1985?)
*/
-
static void
Scheme_functions (inf)
FILE *inf;
}
\f
-/* 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 */
-
/*
* HTML support.
* Contents of <title>, <h1>, <h2>, <h3> are tags.
last[len] = '\0';
}
}
+ if (last != NULL)
+ free (last);
}
|| (s[pos] == '(' && (pos += 1))
|| (s[pos] == ':' && s[pos + 1] == '-' && (pos += 2)))
&& (last == NULL /* save only the first clause */
- || len != strlen (last)
+ || len != (int)strlen (last)
|| !strneq (s, last, len)))
{
make_tag (s, len, TRUE, s, pos, lineno, linecharno);
else if (cp[0] == '-') /* attribute, e.g. "-define" */
{
erlang_attribute (cp);
- last = NULL;
+ if (last != NULL)
+ {
+ free (last);
+ last = NULL;
+ }
}
else if ((len = erlang_func (cp, last)) > 0)
{
last[len] = '\0';
}
}
+ if (last != NULL)
+ free (last);
}
: *s1 - *s2);
}
-/* Skip spaces, return new pointer. */
+/* Skip spaces (end of string is not space), return new pointer. */
static char *
skip_spaces (cp)
char *cp;
return cp;
}
-/* Skip non spaces, return new pointer. */
+/* Skip non spaces, except end of string, return new pointer. */
static char *
skip_non_spaces (cp)
char *cp;
/*
* Local Variables:
- * c-indentation-style: gnu
* indent-tabs-mode: t
* tab-width: 8
* fill-column: 79