Commit 32daa216 authored by Francesco Potortì's avatar Francesco Potortì
Browse files

* etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.

	(main): don't allow the use of -t and -T in etags mode.
	(print_help): don't show options enabled by default.
	(print_version): show the emacs version number if VERSION is #defined.
	(find_entries): add "ss" as suffix for Chez Scheme.
parent 029b623a
...@@ -28,7 +28,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ ...@@ -28,7 +28,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
* Francesco Potorti` (pot@cnuce.cnr.it) is the current maintainer. * Francesco Potorti` (pot@cnuce.cnr.it) is the current maintainer.
*/ */
char etags_version[] = "@(#) pot revision number is 10.15"; char pot_etags_version[] = "@(#) pot revision number is 10.18";
#ifdef MSDOS #ifdef MSDOS
#include <fcntl.h> #include <fcntl.h>
...@@ -53,33 +53,23 @@ extern char *getenv (); ...@@ -53,33 +53,23 @@ extern char *getenv ();
extern char *getcwd (); extern char *getcwd ();
/* Define the symbol ETAGS to make the program "etags", /* Define CTAGS to make the program "ctags" compatible with the usual one.
which makes emacs-style tag tables by default. Let it undefined to make the program "etags", which makes emacs-style
Define CTAGS to make the program "ctags" compatible with the usual one. tag tables and tags typedefs, #defines and struct/union/enum by default. */
Define neither one to get behavior that depends #ifdef CTAGS
on the name with which the program is invoked # undef CTAGS
(but we don't normally compile it that way). */ # define CTAGS TRUE
#else
#if !defined(ETAGS) && !defined(CTAGS) # define CTAGS FALSE
/* If neither is defined, program can be run as either. */
#define ETAGS
#define CTAGS
#endif
/* On VMS, CTAGS is not useful, so always do ETAGS. */
#ifdef VMS
#ifndef ETAGS
#define ETAGS
#endif
#endif #endif
/* Exit codes for success and failure. */ /* Exit codes for success and failure. */
#ifdef VMS #ifdef VMS
#define GOOD (1) #define GOOD 1
#define BAD (0) #define BAD 0
#else #else
#define GOOD (0) #define GOOD 0
#define BAD (1) #define BAD 1
#endif #endif
/* /*
...@@ -247,15 +237,13 @@ char *curfile, /* current input file name */ ...@@ -247,15 +237,13 @@ char *curfile, /* current input file name */
*intk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789"; *intk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789";
int append_to_tagfile; /* -a: append to tags */ int append_to_tagfile; /* -a: append to tags */
int emacs_tags_format; /* emacs style output (no -e option any more) */
/* The following three default to 1 for etags, but to 0 for ctags. */ /* The following three default to 1 for etags, but to 0 for ctags. */
int typedefs; /* -t: create tags for typedefs */ int typedefs; /* -t: create tags for typedefs */
int typedefs_and_cplusplus; /* -T: create tags for typedefs, level */ int typedefs_and_cplusplus; /* -T: create tags for typedefs, level */
/* 0 struct/enum/union decls, and C++ */ /* 0 struct/enum/union decls, and C++ */
/* member functions */ /* member functions. */
int constantypedefs; /* -d: create tags for C #define and enum */ int constantypedefs; /* -d: create tags for C #define and enum */
/* constants. Default under etags. Enum */ /* constants. Enum consts not implemented. */
/* constants not implemented. */
/* -D: opposite of -d. Default under ctags. */ /* -D: opposite of -d. Default under ctags. */
int update; /* -u: update tags */ int update; /* -u: update tags */
int vgrind_style; /* -v: create vgrind style index output */ int vgrind_style; /* -v: create vgrind style index output */
...@@ -316,16 +304,11 @@ struct ...@@ -316,16 +304,11 @@ struct
void void
print_version () print_version ()
{ {
#ifdef CTAGS #ifdef VERSION
printf ("CTAGS "); printf ("%s for Emacs version %g.\n", (CTAGS) ? "CTAGS" : "ETAGS", VERSION);
#ifdef ETAGS #else
printf ("and "); printf ("%s for Emacs version 19.\n", (CTAGS) ? "CTAGS" : "ETAGS");
#endif #endif
#endif
#ifdef ETAGS
printf ("ETAGS ");
#endif
printf ("for Emacs version 19.\n");
exit (GOOD); exit (GOOD);
} }
...@@ -340,48 +323,34 @@ names from stdin.\n\n", progname); ...@@ -340,48 +323,34 @@ names from stdin.\n\n", progname);
puts ("-a, --append\n\ puts ("-a, --append\n\
Append tag entries to existing tags file."); Append tag entries to existing tags file.");
#ifdef CTAGS if (CTAGS)
puts ("-B, --backward-search\n\ puts ("-B, --backward-search\n\
Write the search commands for the tag entries using '?', the\n\ Write the search commands for the tag entries using '?', the\n\
backward-search command."); backward-search command.");
#endif
puts ("-C, --c++\n\ puts ("-C, --c++\n\
Treat files with `.c' and `.h' extensions as C++ code, not C\n\ Treat files with `.c' and `.h' extensions as C++ code, not C\n\
code. Files with `.C', `.H', `.cxx', `.hxx', or `.cc'\n\ code. Files with `.C', `.H', `.cxx', `.hxx', or `.cc'\n\
extensions are always assumed to be C++ code."); extensions are always assumed to be C++ code.");
#ifdef ETAGS if (CTAGS)
puts ("-d, --defines\n\ puts ("-d, --defines\n\
Create tag entries for #defines, too. This is the default\n\ Create tag entries for C #defines, too.");
behavior."); else
#else puts ("-D, --no-defines\n\
puts ("-d, --defines\n\ Don't create tag entries for C #defines. This makes the tags\n\
Create tag entries for #defines, too."); file smaller.");
#endif
#ifdef CTAGS
puts ("-D, --no-defines\n\
Don't create tag entries for #defines. This is the default\n\
behavior.");
#else
puts ("-D, --no-defines\n\
Don't create tag entries for #defines.");
#endif
#ifdef CTAGS if (CTAGS)
puts ("-F, --forward-search\n\ puts ("-F, --forward-search\n\
Write the search commands for the tag entries using '/', the\n\ Write the search commands for the tag entries using '/', the\n\
forward-search command."); forward-search command.");
#endif
if (!CTAGS)
#ifdef ETAGS puts ("-i FILE, --include=FILE\n\
puts ("-i FILE, --include=FILE\n\
Include a note in tag file indicating that, when searching for\n\ Include a note in tag file indicating that, when searching for\n\
a tag, one should also consult the tags file FILE after\n\ a tag, one should also consult the tags file FILE after\n\
checking the current file."); checking the current file.");
#endif
puts ("-o FILE, --output=FILE\n\ puts ("-o FILE, --output=FILE\n\
Write the tags to FILE."); Write the tags to FILE.");
...@@ -389,35 +358,39 @@ names from stdin.\n\n", progname); ...@@ -389,35 +358,39 @@ names from stdin.\n\n", progname);
Don't rely on indentation quite as much as normal. Currently,\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\ this means not to assume that a closing brace in the first\n\
column is the final brace of a function or structure\n\ column is the final brace of a function or structure\n\
definition."); definition in C and C++.");
puts ("-t, --typedefs\n\
Generate tag entries for typedefs. This is the default\n\
behavior.");
puts ("-T, --typedefs-and-c++\n\
Generate tag entries for typedefs, struct/enum/union tags, and\n\
C++ member functions.");
#ifdef CTAGS if (CTAGS)
puts ("-u, --update\n\ {
puts ("-t, --typedefs\n\
Generate tag entries for C typedefs.");
puts ("-T, --typedefs-and-c++\n\
Generate tag entries for C typedefs, C struct/enum/union tags,\n\
and C++ member functions.");
}
if (CTAGS)
{
puts ("-u, --update\n\
Update the tag entries for the given files, leaving tag\n\ Update the tag entries for the given files, leaving tag\n\
entries for other files in place. Currently, this is\n\ entries for other files in place. Currently, this is\n\
implemented by deleting the existing entries for the given\n\ implemented by deleting the existing entries for the given\n\
files and then rewriting the new entries at the end of the\n\ files and then rewriting the new entries at the end of the\n\
tags file. It is often faster to simply rebuild the entire\n\ tags file. It is often faster to simply rebuild the entire\n\
tag file than to use this."); tag file than to use this.");
puts ("-v, --vgrind\n\ puts ("-v, --vgrind\n\
Generates an index of items intended for human consumption,\n\ Generates an index of items intended for human consumption,\n\
similar to the output of vgrind. The index is sorted, and\n\ similar to the output of vgrind. The index is sorted, and\n\
gives the page number of each item."); gives the page number of each item.");
puts ("-x, --cxref\n\ puts ("-x, --cxref\n\
Like --vgrind, but in the style of cxref, rather than vgrind.\n\ Like --vgrind, but in the style of cxref, rather than vgrind.\n\
The output uses line numbers instead of page numbers, but\n\ The output uses line numbers instead of page numbers, but\n\
beyond that the differences are cosmetic; try both to see\n\ beyond that the differences are cosmetic; try both to see\n\
which you like."); which you like.");
puts ("-w, --no-warn\n\ puts ("-w, --no-warn\n\
Suppress warning messages about entries defined in multiple\n\ Suppress warning messages about entries defined in multiple\n\
files."); files.");
#endif }
puts ("-V, --version\n\ puts ("-V, --version\n\
Print the version of the program.\n\ Print the version of the program.\n\
...@@ -451,23 +424,17 @@ main (argc, argv) ...@@ -451,23 +424,17 @@ main (argc, argv)
progname = argv[0]; progname = argv[0];
#ifndef CTAGS
emacs_tags_format = 1;
#else
emacs_tags_format = 0;
#endif
/* /*
* If etags, always find typedefs and structure tags. Why not? * If etags, always find typedefs and structure tags. Why not?
* Also default is to find macro constants. * Also default is to find macro constants.
*/ */
if (emacs_tags_format) if (!CTAGS)
typedefs = typedefs_and_cplusplus = constantypedefs = 1; typedefs = typedefs_and_cplusplus = constantypedefs = 1;
for (;;) for (;;)
{ {
int opt; int opt;
opt = getopt_long (argc, argv, "aCdDo:f:StTi:BFuvxwVH", longopts, 0); opt = getopt_long (argc, argv, "aCdDf:o:StTi:BFuvxwVH", longopts, 0);
if (opt == EOF) if (opt == EOF)
break; break;
...@@ -492,7 +459,7 @@ main (argc, argv) ...@@ -492,7 +459,7 @@ main (argc, argv)
case 'D': case 'D':
constantypedefs = 0; constantypedefs = 0;
break; break;
case 'f': case 'f': /* for compatibility with old makefiles */
case 'o': case 'o':
if (outfile) if (outfile)
{ {
...@@ -505,13 +472,6 @@ main (argc, argv) ...@@ -505,13 +472,6 @@ main (argc, argv)
case 'S': case 'S':
noindentypedefs++; noindentypedefs++;
break; break;
case 't':
typedefs++;
break;
case 'T':
typedefs++;
typedefs_and_cplusplus++;
break;
case 'V': case 'V':
print_version (); print_version ();
break; break;
...@@ -521,7 +481,7 @@ main (argc, argv) ...@@ -521,7 +481,7 @@ main (argc, argv)
/* Etags options */ /* Etags options */
case 'i': case 'i':
if (!emacs_tags_format) if (CTAGS)
goto usage; goto usage;
included_files[nincluded_files++] = optarg; included_files[nincluded_files++] = optarg;
break; break;
...@@ -529,31 +489,35 @@ main (argc, argv) ...@@ -529,31 +489,35 @@ main (argc, argv)
/* Ctags options. */ /* Ctags options. */
case 'B': case 'B':
searchar = '?'; searchar = '?';
if (emacs_tags_format) if (!CTAGS) goto usage;
goto usage;
break; break;
case 'F': case 'F':
searchar = '/'; searchar = '/';
if (emacs_tags_format) if (!CTAGS) goto usage;
goto usage; break;
case 't':
typedefs++;
if (!CTAGS) goto usage;
break;
case 'T':
typedefs++;
typedefs_and_cplusplus++;
if (!CTAGS) goto usage;
break; break;
case 'u': case 'u':
update++; update++;
if (emacs_tags_format) if (!CTAGS) goto usage;
goto usage;
break; break;
case 'v': case 'v':
vgrind_style++; vgrind_style++;
/*FALLTHRU*/ /*FALLTHRU*/
case 'x': case 'x':
cxref_style++; cxref_style++;
if (emacs_tags_format) if (!CTAGS) goto usage;
goto usage;
break; break;
case 'w': case 'w':
no_warnings++; no_warnings++;
if (emacs_tags_format) if (!CTAGS) goto usage;
goto usage;
break; break;
default: default:
...@@ -573,7 +537,7 @@ main (argc, argv) ...@@ -573,7 +537,7 @@ main (argc, argv)
if (outfile == NULL) if (outfile == NULL)
{ {
outfile = emacs_tags_format ? "TAGS" : "tags"; outfile = CTAGS ? "tags" : "TAGS";
} }
getcwd (cwd, BUFSIZ); /* the current working directory */ getcwd (cwd, BUFSIZ); /* the current working directory */
strcat (cwd, "/"); strcat (cwd, "/");
...@@ -595,7 +559,7 @@ main (argc, argv) ...@@ -595,7 +559,7 @@ main (argc, argv)
/* /*
* loop through files finding functions * loop through files finding functions
*/ */
if (emacs_tags_format) if (!CTAGS)
{ {
if (streq (outfile, "-")) if (streq (outfile, "-"))
outf = stdout; outf = stdout;
...@@ -644,7 +608,7 @@ main (argc, argv) ...@@ -644,7 +608,7 @@ main (argc, argv)
process_file (this_file); process_file (this_file);
} }
if (emacs_tags_format) if (!CTAGS)
{ {
while (nincluded_files-- > 0) while (nincluded_files-- > 0)
fprintf (outf, "\f\n%s,include\n", *included_files++); fprintf (outf, "\f\n%s,include\n", *included_files++);
...@@ -711,7 +675,7 @@ process_file (file) ...@@ -711,7 +675,7 @@ process_file (file)
{ {
return; return;
} }
if (emacs_tags_format) if (!CTAGS)
{ {
char *filename; char *filename;
...@@ -809,6 +773,7 @@ find_entries (file) ...@@ -809,6 +773,7 @@ find_entries (file)
|| streq (cp + 1, "scheme") || streq (cp + 1, "scheme")
|| streq (cp + 1, "t") || streq (cp + 1, "t")
|| streq (cp + 1, "sch") || streq (cp + 1, "sch")
|| streq (cp + 1, "ss")
|| streq (cp + 1, "SM") || streq (cp + 1, "SM")
|| streq (cp + 1, "SCM") || streq (cp + 1, "SCM")
/* The `SCM' or `scm' prefix with a version number */ /* The `SCM' or `scm' prefix with a version number */
...@@ -923,7 +888,7 @@ pfnote (name, is_func, named, linestart, linelen, lno, cno) ...@@ -923,7 +888,7 @@ pfnote (name, is_func, named, linestart, linelen, lno, cno)
np = xnew (1, NODE); np = xnew (1, NODE);
if (np == NULL) if (np == NULL)
{ {
if (!emacs_tags_format) if (CTAGS)
{ {
/* It's okay to output early in etags -- it only disrupts the /* It's okay to output early in etags -- it only disrupts the
* character count of the tag entries, which is no longer used * character count of the tag entries, which is no longer used
...@@ -937,7 +902,7 @@ pfnote (name, is_func, named, linestart, linelen, lno, cno) ...@@ -937,7 +902,7 @@ pfnote (name, is_func, named, linestart, linelen, lno, cno)
np = xnew (1, NODE); np = xnew (1, NODE);
} }
/* If ctags mode, change name "main" to M<thisfilename>. */ /* If ctags mode, change name "main" to M<thisfilename>. */
if (!emacs_tags_format && !cxref_style && streq (name, "main")) if (CTAGS && !cxref_style && streq (name, "main"))
{ {
fp = etags_rindex (curfile, '/'); fp = etags_rindex (curfile, '/');
name = concat ("M", fp == 0 ? curfile : fp + 1, ""); name = concat ("M", fp == 0 ? curfile : fp + 1, "");
...@@ -954,7 +919,7 @@ pfnote (name, is_func, named, linestart, linelen, lno, cno) ...@@ -954,7 +919,7 @@ pfnote (name, is_func, named, linestart, linelen, lno, cno)
/* UNCOMMENT THE +1 HERE: */ /* UNCOMMENT THE +1 HERE: */
np->cno = cno /* + 1 */ ; /* our char numbers are 0-base; emacs's are 1-base */ np->cno = cno /* + 1 */ ; /* our char numbers are 0-base; emacs's are 1-base */
np->left = np->right = 0; np->left = np->right = 0;
if (emacs_tags_format) if (!CTAGS)
{ {
c = linestart[linelen]; c = linestart[linelen];
linestart[linelen] = 0; linestart[linelen] = 0;
...@@ -965,7 +930,7 @@ pfnote (name, is_func, named, linestart, linelen, lno, cno) ...@@ -965,7 +930,7 @@ pfnote (name, is_func, named, linestart, linelen, lno, cno)
linestart = tem; linestart = tem;
} }
np->pat = savestr (linestart); np->pat = savestr (linestart);
if (emacs_tags_format) if (!CTAGS)
{ {
linestart[linelen] = c; linestart[linelen] = c;
} }
...@@ -1019,7 +984,7 @@ add_node (node, cur_node_p) ...@@ -1019,7 +984,7 @@ add_node (node, cur_node_p)
return; return;
} }
if (emacs_tags_format) if (!CTAGS)
{ {
/* Etags Mode */ /* Etags Mode */
if (last_node == NULL) if (last_node == NULL)
...@@ -1085,7 +1050,7 @@ put_entries (node) ...@@ -1085,7 +1050,7 @@ put_entries (node)
/* Output this entry */ /* Output this entry */
if (emacs_tags_format) if (!CTAGS)
{ {
if (node->named) if (node->named)
{ {
...@@ -1150,9 +1115,10 @@ number_len (num) ...@@ -1150,9 +1115,10 @@ number_len (num)
/* /*
* Return total number of characters that put_entries will output for * Return total number of characters that put_entries will output for
* the nodes in the subtree of the specified node. Works only if emacs_tags_format * the nodes in the subtree of the specified node. Works only if
* is set, but called only in that case. This count is irrelevant with * we are not ctags, but called only in that case. This count
* the new tags.el, but is still supplied for backward compatibility. * is irrelevant with the new tags.el, but is still supplied for
* backward compatibility.
*/ */
int int
total_size_of_entries (node) total_size_of_entries (node)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment