]> git.eshelyaron.com Git - emacs.git/commitdiff
Remove ctags program
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 22 Mar 2025 18:19:41 +0000 (11:19 -0700)
committerEshel Yaron <me@eshelyaron.com>
Sun, 23 Mar 2025 19:33:43 +0000 (20:33 +0100)
Remove our old ctags and suggest Universal Ctags instead.
This fixes a FIXME in lib-src/Makefile.in and speeds up compilation
quite a bit on my older CPU when I compile with --enable-gcc-warnings.
It also lessens installation and runtime footprint. (Bug#76322)
* .gitignore: Remove lib-src/ctags.
* admin/authors.el (authors-renamed-files-alist): Remove ctags.1.
* admin/check-man-pages: ctags.1 is no longer a special case.
* admin/quick-install-emacs (PUBLIC_LIBSRC_BINARIES): Remove ctags.
* cross/Makefile.in (LIBSRC_BINARIES): Remove lib-src/ctags.
* doc/man/ctags.1, lib-src/ctags.c: Remove.
* java/Makefile.in (CROSS_LIBSRC_BINS): Remove ctags.
* lib-src/Makefile.in (INSTALLABLES): Remove ctags${EXEEXT}.
(ctags${EXEEXT}): Remove.
* lib-src/etags.c (CTAGS): Remove.  All uses replaced by ...
(ctags): ... this new static var.
(STDIN): Remove macro.  All uses replaced by new STDIN_OPTION constant.
(CTAGS_OPTION, STDIN_OPTION): New contants.
(longopts): New --ctags option.
(ctags_default_C_help): New constant,
to override default_C_help at runtime.
(default_C_help): Now always the etags version.
(C_LANG_NAMES_INDEX): New macro.
(print_language_names): Do not assume etags.
(PROGRAM_NAME): Remove.  All uses removed.
(print_help): Document --ctags if PRINT_UNDOCUMENTED_OPTIONS_HELP.
(main): Support new --ctags option, and support all [ce]tags options.
* test/manual/etags/Makefile (CTAGS_PROG):
Now etags --ctags, since there is no longer a ctags.

(cherry picked from commit 25d757535884da71ace29fd80b8b24dd3a8f9017)

19 files changed:
.gitignore
INSTALL
Makefile.in
admin/authors.el
admin/check-man-pages
admin/quick-install-emacs
cross/Makefile.in
doc/emacs/android.texi
doc/lispref/processes.texi
doc/man/ctags.1 [deleted file]
doc/man/etags.1
etc/PROBLEMS
java/Makefile.in
lib-src/Makefile.in
lib-src/ctags.c [deleted file]
lib-src/etags.c
nt/README
nt/README.W32
src/callproc.c

index 71ae17fc38169a4c60bb121f4a022fbb19498ed8..5ad28c30e12411e6eb027d0a08039cfda7b14657 100644 (file)
@@ -200,7 +200,7 @@ test/infra/android/**/*.zip
 test/infra/android/**/*.jar
 test/infra/android/bin/build.sh
 
-# ctags, etags.
+# etags.
 TAGS
 !admin/notes/tags
 
@@ -225,7 +225,6 @@ a.out
 lib-src/asset-directory-tool
 lib-src/be-resources
 lib-src/blessmail
-lib-src/ctags
 lib-src/emacsclient
 lib-src/etags
 lib-src/hexl
diff --git a/INSTALL b/INSTALL
index d38fff7b2e6e3ff31f6a2f1f2f066f137746def9..40cb674d48ff8b445ae8679e595d873268d1c863 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -612,7 +612,7 @@ installed locations, with 'make install'.  By default, Emacs's files
 are installed in the following directories:
 
 '/usr/local/bin' holds the executable programs users normally run -
-               'emacs', 'etags', 'ctags', 'emacsclient'.
+               'emacs', 'etags', 'emacsclient'.
 
 '/usr/local/share/emacs/VERSION/lisp' holds the Emacs Lisp library;
                'VERSION' stands for the number of the Emacs version
index fd85c1cbd8a1059010cb383c71160797aba3e890..35bae8cee6a9e283e0e429b4cefb34aa8bf7ff7e 100644 (file)
@@ -812,9 +812,7 @@ install-info: info
 
 ## "gzip || true" is because some gzips exit with non-zero status
 ## if compression would not reduce the file size.  Eg, the gzip in
-## OpenBSD 4.9 seems to do this (2013/03).  In Emacs, this can
-## only happen with the tiny ctags.1 manpage.  We don't really care if
-## ctags.1 is compressed or not.  "gzip -f" is another option here,
+## OpenBSD 4.9 seems to do this (2013/03).  "gzip -f" is another option here,
 ## but not sure if portable.
 install-man:
        umask 022; ${MKDIR_P} "$(DESTDIR)${man1dir}"
index 4cf1bca3aebeb79d1d6fbced7c7abcdd3d224d83..aaf0a4c172498fe12f221279bbdcfda174020679 100644 (file)
@@ -1391,7 +1391,6 @@ in the repository.")
     ("org/COPYRIGHT-AND-LICENSE" . "org/README")
     ("lisp/net/idna.el" . "puny.el")
     ;; Moved to different directories.
-    ("ctags.1" . "ctags.1")
     ("etags.1" . "etags.1")
     ("emacs.1" . "emacs.1")
     ("emacsclient.1" . "emacsclient.1")
index 409003e0462a07460eee9c74866621fb10e5865f..84ca56bf08432a5f678a7720db25eb46bbd934f4 100755 (executable)
@@ -32,13 +32,6 @@ exit_status=0
 
 cd "$PD"/../doc/man
 for page in *.1; do
-    # ctags.1 just includes the man page etags.1, which AFAICT will
-    # default to the one installed on the system (!), instead of the
-    # one in the repository.  So checking it is pointless, and we will
-    # in any case already check etags.1 separately.
-    if [ "$page" == "ctags.1" ]; then
-        continue
-    fi
     log=$(emacs_mktemp)
     LC_ALL=C.UTF-8 MANROFFSEQ='' MANWIDTH=80 \
         man --warnings=all,mac -E UTF-8 -l -Tutf8 -Z "$page" >/dev/null 2> "$log"
index 882fcc1ce84b38551678cede9e5969eb4a0f0e75..a434a0e8784ad540be6672e9ed6056713f755482 100755 (executable)
@@ -26,8 +26,7 @@
 ## This script is mainly intended for emacs maintainer or pretesters who
 ## install emacs very often.  See the --help output for more details.
 
-
-PUBLIC_LIBSRC_BINARIES='emacsclient etags ctags'
+PUBLIC_LIBSRC_BINARIES='emacsclient etags'
 
 AVOID="CVS -DIC README COPYING ChangeLog ~ [.]orig$ [.]rej$ Makefile$ Makefile.in$ makefile$ makefile.w32-in$ stamp-subdir [.]cvsignore [.]arch-ids [{]arch[}] [.][cho]$ make-docfile"
 
index c008ebf861ea7cb205f7434cb37b457f24b2e36e..59d080e17ec0a6e64fdb9ef428739d1508116c3e 100644 (file)
@@ -50,7 +50,7 @@ LIB_SRC_TOP_SRCDIR = $(realpath $(top_src))
 
 # This is a list of binaries to build and install in lib-src.
 
-LIBSRC_BINARIES = lib-src/etags lib-src/ctags lib-src/emacsclient \
+LIBSRC_BINARIES = lib-src/etags lib-src/emacsclient \
                  lib-src/hexl lib-src/movemail
 
 CLEAN_SUBDIRS = $(wildcard src lib-src lib etc)
index 17bb133cbd8361e46e53907b33ade75f3aaec078..3f316e3e2637d1b6ac684f4d0e588fd5eac10627 100644 (file)
@@ -353,11 +353,11 @@ directories and the app data directories of other applications.
   The Emacs distribution also incorporates several binaries.  While
 being executable files, they are packaged as libraries in the library
 directory, because otherwise the system will not unpack them while
-Emacs is being installed.  This means that instead of @code{ctags} or
-@code{emacsclient}, Lisp code must specify @code{libctags.so} or
+Emacs is being installed.  This means that instead of
+@code{emacsclient}, Lisp code must specify
 @code{libemacsclient.so} on the command line when starting either of
 those programs in a subprocess; to determine which names to use,
-consult the values of the variables @code{ctags-program-name},
+consult the values of the variables
 @code{etags-program-name}, @code{hexl-program-name},
 @code{emacsclient-program-name}, @code{movemail-program-name},
 and @code{rcs2log-program-name}.
index 46212867d5848e8e5f97e46c53ca1ab791533805..7fab68ad89c5d86ce48dca86642d4b84fc8bba33 100644 (file)
@@ -186,7 +186,6 @@ the function returns just the value of the variable @code{exec-path}.
 @end defun
 
 @cindex programs distributed with Emacs, starting
-@vindex ctags-program-name
 @vindex etags-program-name
 @vindex hexl-program-name
 @vindex emacsclient-program-name
@@ -196,8 +195,8 @@ the function returns just the value of the variable @code{exec-path}.
 must take into account that the program may have been renamed in order
 to comply with executable naming restrictions present on the system.
 
-  Instead of starting @command{ctags}, for example, you should specify
-the value of @code{ctags-program-name} instead.  Likewise, instead of
+  Instead of starting @command{emacsclient}, for example, you should specify
+the value of @code{emacsclient-program-name} instead.  Likewise, instead of
 starting @command{movemail}, you must start
 @code{movemail-program-name}, and the same goes for @command{etags},
 @command{hexl}, @command{emacsclient}, and @code{rcs2log}.
diff --git a/doc/man/ctags.1 b/doc/man/ctags.1
deleted file mode 100644 (file)
index 1eab02f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-.so man1/etags.1
index 3c0a7486f582267aaa58a002b2be634d54f9d8bc..649e54695b4243917f26cd3eb7b22b63cf874117 100644 (file)
@@ -1,5 +1,5 @@
 .\" See section COPYING for copyright and redistribution information.
-.TH ETAGS 1 "2024-12-15" "GNU Tools" "GNU"
+.TH ETAGS 1 "2025-03-22" "GNU Tools" "GNU"
 .de BP
 .sp
 .ti -.2i
@@ -7,7 +7,7 @@
 ..
 
 .SH NAME
-etags, ctags \- generate tag file for Emacs, vi
+etags \- generate tag file for Emacs, vi
 .SH SYNOPSIS
 .hy 0
 .na
@@ -25,7 +25,7 @@ etags, ctags \- generate tag file for Emacs, vi
 [\|\-\-help\|] [\|\-\-version\|]
 \fIfile\fP .\|.\|.
 
-\fBctags\fP [\|\-aCdgIQRVh\|] [\|\-BtTuvwx\|] [\|\-l \fIlanguage\fP\|]
+\fBetags \-\-ctags\fP [\|\-aCdgIQRVh\|] [\|\-BtTuvwx\|] [\|\-l \fIlanguage\fP\|]
 .if n .br
 [\|\-o \fItagfile\fP\|] [\|\-r \fIregexp\fP\|]
 [\|\-\-parse\-stdin=\fIfile\fP\|]
@@ -45,17 +45,18 @@ etags, ctags \- generate tag file for Emacs, vi
 The \|\fBetags\fP\| program is used to create a tag table file, in a format
 understood by
 .BR emacs ( 1 )\c
-\&; the \|\fBctags\fP\| program is used to create a similar table in a
+\&; if the first argument is the obsolescent option \|\fB\-\-ctags\fP\|
+the program instead creates a similar table in a
 format understood by
 .BR vi ( 1 )\c
-\&.  Both forms of the program understand
+\&.  The program understands
 the syntax of C, Objective C, C++, Java, Fortran, Ada, Cobol, Erlang,
 Forth, Go, HTML, LaTeX, Emacs Lisp/Common Lisp, Lua, Makefile, Mercury, Pascal,
 Perl, Ruby, Rust, PHP, PostScript, Python, Prolog, Scheme and most
 assembler\-like syntaxes.
-Both forms read the files specified on the command line, and write a tag
-table (defaults: \fBTAGS\fP for \fBetags\fP, \fBtags\fP for
-\fBctags\fP) in the current working directory.
+It reads the files specified on the command line, and write a tag
+table (default: \fBTAGS\fP, or \fBtags\fP if
+\fB\-\-ctags\fP is used) in the current working directory.
 Files specified with relative file names will be recorded in the tag
 table with file names relative to the directory where the tag table
 resides.  If the tag table is in /dev or is the standard output,
@@ -71,8 +72,7 @@ parsing of the file names following the switch according to the given
 language, overriding guesses based on filename extensions.
 .SH OPTIONS
 Some options make sense only for the \fBvi\fP style tag files produced
-by ctags;
-\fBetags\fP does not recognize them.
+with the \fB\-\-ctags\fP option; they are ignored otherwise.
 The programs accept unambiguous abbreviations for long option names.
 .TP
 .B \-a, \-\-append
@@ -85,7 +85,7 @@ expression search instructions; the \fB\-B\fP option writes them using
 the delimiter "\|\fB?\fP\|", to search \fIbackwards\fP through files.
 The default is to use the delimiter "\|\fB/\fP\|", to search \fIforwards\fP
 through files.
-Only \fBctags\fP accepts this option.
+This option makes sense only if \fB\-\-ctags\fP is used.
 .TP
 .B \-\-declarations
 In C and derived languages, create tags for function declarations,
@@ -183,7 +183,7 @@ the previous ones.  The regexps are of one of the forms:
 where \fItagregexp\fP is used to match the tag.  It should not match
 useless characters.  If the match is such that more characters than
 needed are unavoidably matched by \fItagregexp\fP, it may be useful to
-add a \fInameregexp\fP, to narrow down the tag scope.  \fBctags\fP
+add a \fInameregexp\fP, to narrow down the tag scope.  \fB\-\-ctags\fP
 ignores regexps without a \fInameregexp\fP.  The syntax of regexps is
 the same as in Emacs, except that backslash escapes are the same
 as GNU grep (which means, for example, that shy groups are not supported),
@@ -265,15 +265,17 @@ tag entries for other files in place.  Currently, this is implemented
 by deleting the existing entries for the given files and then
 rewriting the new entries at the end of the tags file.  It is often
 faster to simply rebuild the entire tag file than to use this.
-Only \fBctags\fP accepts this option.
+This option makes sense only if \fB\-\-ctags\fP is used.
 .TP
 .B \-v, \-\-vgrind
 Instead of generating a tag file, write index (in \fBvgrind\fP format)
-to standard output.  Only \fBctags\fP accepts this option.
+to standard output.
+This option makes sense only if \fB\-\-ctags\fP is used.
 .TP
 .B \-x, \-\-cxref
 Instead of generating a tag file, write a cross reference (in
-\fBcxref\fP format) to standard output.  Only \fBctags\fP accepts this option.
+\fBcxref\fP format) to standard output.
+This option makes sense only if \fB\-\-ctags\fP is used.
 .TP
 .B \-h, \-H, \-\-help
 Print usage information.  Followed by one or more \-\-language=LANG
index 0d61a3bc76edf7d385a0ac5561246a5b0cc3b34b..952813f0c5b1fd2ee8cf0cfa7a57bfdf6aaf2dc2 100644 (file)
@@ -3973,7 +3973,7 @@ There are several known workarounds:
 
 The linker error messages look like this:
 
- oo-spd/i386/ctags.o:ctags.c:(.text+0x156e): undefined reference to `_imp__re_set_syntax'
+ oo-spd/i386/etags.o:etags.c:(.text+0x156e): undefined reference to `_imp__re_set_syntax'
  collect2: ld returned 1 exit status
 
 This happens because GCC finds an incompatible regex.h header
@@ -4004,7 +4004,7 @@ Some versions of mingw32 make on some versions of Windows do not seem
 to detect the shell correctly.  Try "make SHELL=cmd.exe", or if that
 fails, try running make from Cygwin bash instead.
 
-*** Building 'ctags' for MS-Windows with the MinGW port of GCC fails.
+*** Building 'etags' for MS-Windows with the MinGW port of GCC fails.
 
 This might happen due to a bug in the MinGW header assert.h, which
 defines the 'assert' macro with a trailing semi-colon.  The following
index f0112911ca0d44e645efa14ef0f7959dd57827a1..6aeca75ea7c318c37f09481f408f87683f826969 100644 (file)
@@ -128,7 +128,6 @@ IS_D8_R8 := @IS_D8_R8@
 # containing the following files:
 #  lib/$(ANDROID_ABI)/libemacs.so
 #  lib/$(ANDROID_ABI)/libandroid-emacs.so
-#  lib/$(ANDROID_ABI)/libctags.so
 #  lib/$(ANDROID_ABI)/libetags.so
 #  lib/$(ANDROID_ABI)/libhexl.so
 #  lib/$(ANDROID_ABI)/libmovemail.so
@@ -143,8 +142,7 @@ all: $(APK_NAME)
 
 # Binaries to cross-compile.
 CROSS_SRC_BINS := $(top_builddir)/cross/src/android-emacs
-CROSS_LIBSRC_BINS := $(top_builddir)/cross/lib-src/ctags       \
-                    $(top_builddir)/cross/lib-src/hexl         \
+CROSS_LIBSRC_BINS := $(top_builddir)/cross/lib-src/hexl                \
                     $(top_builddir)/cross/lib-src/emacsclient  \
                     $(top_builddir)/cross/lib-src/etags
 CROSS_LIBSRC_BINS_MOVEMAIL := $(top_builddir)/cross/lib-src/movemail
index 2f942b49f142eeb4e52eb08ed12e97bcee5cd32e..1abfafbe4c8a85b6ca184a9e099e9e744e53f6be 100644 (file)
@@ -155,7 +155,7 @@ ANDROID=@ANDROID@
 CLIENTW = @CLIENTW@
 
 # Things that a user might actually run, which should be installed in bindir.
-INSTALLABLES = etags${EXEEXT} ctags${EXEEXT} emacsclient${EXEEXT} $(CLIENTW)
+INSTALLABLES = etags${EXEEXT} emacsclient${EXEEXT} $(CLIENTW)
 
 # Things that Emacs runs internally, or during the build process,
 #  which should not be installed in bindir.
@@ -414,13 +414,6 @@ etags_libs = $(NTLIB) $(LOADLIBES) $(LIBS_ETAGS)
 etags${EXEEXT}: ${etags_deps}
        $(AM_V_CCLD)$(CC) ${ALL_CFLAGS} -o $@ $< $(etags_libs)
 
-## ctags.c is distinct from etags.c so that parallel makes do not write two
-## etags.o files on top of each other.
-## FIXME?
-## Can't we use a wrapper that calls 'etags --ctags'?
-ctags${EXEEXT}: ${srcdir}/ctags.c ${etags_deps}
-       $(AM_V_CCLD)$(CC) ${ALL_CFLAGS} -o $@ $< $(etags_libs)
-
 asset-directory-tool${EXEEXT}: ${srcdir}/asset-directory-tool.c $(config_h)
        $(AM_V_CCLD)$(CC) ${ALL_CFLAGS} $< $(LOADLIBES) -o $@
 
diff --git a/lib-src/ctags.c b/lib-src/ctags.c
deleted file mode 100644 (file)
index 0a6838a..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-#define CTAGS 1
-#include "etags.c"
index ab7e6626cf8071cef8b870ee3b1f648317da8a42..a247246176d07534e0efe38fb66e505607512869 100644 (file)
@@ -126,16 +126,6 @@ University of California, as described above. */
 #include <getopt.h>
 #include <regex.h>
 
-/* Define CTAGS to make the program "ctags" compatible with the usual one.
- Leave it undefined to make the program "etags", which makes emacs-style
- tag tables and tags typedefs, #defines and struct/union/enum by default. */
-#ifdef CTAGS
-# undef  CTAGS
-# define CTAGS true
-#else
-# define CTAGS false
-#endif
-
 /* Define MERCURY_HEURISTICS_RATIO as it was necessary to disambiguate
    Mercury from Objective C, which have same file extensions .m
    See comments before function test_objc_is_mercury for details.  */
@@ -465,12 +455,12 @@ static bool typedefs_or_cplusplus; /* -T: create tags for C typedefs, level */
                                /* member functions. */
 static bool constantypedefs;   /* -d: create tags for C #define, enum */
                                /* constants and variables. */
-                               /* -D: opposite of -d.  Default under ctags. */
+                               /* -D: opposite of -d.  Default if ctags. */
 static int globals;            /* create tags for global variables */
 static int members;            /* create tags for C member variables */
 static int declarations;       /* --declarations: tag them and extern in C&Co*/
 static int no_line_directive;  /* ignore #line directives (undocumented) */
-static int no_duplicates;      /* no duplicate tags for ctags (undocumented) */
+static int no_duplicates;      /* no duplicate tags if ctags (undocumented) */
 static bool update;            /* -u: update tags */
 static bool vgrind_style;      /* -v: create vgrind style index output */
 static bool no_warnings;       /* -w: suppress warnings (undocumented) */
@@ -479,16 +469,20 @@ static bool cplusplus;            /* .[hc] means C++, not C (undocumented) */
 static bool ignoreindent;      /* -I: ignore indentation in C */
 static int packages_only;      /* --packages-only: in Ada, only tag packages*/
 static int class_qualify;      /* -Q: produce class-qualified tags in C++/Java */
+static bool ctags;             /* --ctags */
 static int debug;              /* --debug */
-
-/* STDIN is defined in LynxOS system headers */
-#ifdef STDIN
-# undef STDIN
-#endif
-
-#define STDIN 0x1001           /* returned by getopt_long on --parse-stdin */
+static int fallback_lang;      /* --(no-)fallback-lang: Fortran/C fallbacks */
+static int empty_files;                /* --(no-)empty-file-entries */
 static bool parsing_stdin;     /* --parse-stdin used */
 
+/* For long options that have no equivalent short option, use a
+   non-character as a pseudo short option, starting with CHAR_MAX + 1.  */
+enum
+  {
+    CTAGS_OPTION = CHAR_MAX + 1,
+    STDIN_OPTION
+  };
+
 static regexp *p_head;         /* list of all regexps */
 static bool need_filebuf;      /* some regexes are multi-line */
 
@@ -497,6 +491,7 @@ static struct option longopts[] =
   { "append",             no_argument,       NULL,               'a'   },
   { "packages-only",      no_argument,       &packages_only,     1     },
   { "c++",                no_argument,       NULL,               'C'   },
+  { "ctags",              no_argument,       NULL,        CTAGS_OPTION },
   { "debug",              no_argument,       &debug,             1     },
   { "declarations",       no_argument,       &declarations,      1     },
   { "no-line-directive",  no_argument,       &no_line_directive, 1     },
@@ -512,10 +507,10 @@ static struct option longopts[] =
   { "regex",              required_argument, NULL,               'r'   },
   { "no-regex",           no_argument,       NULL,               'R'   },
   { "ignore-case-regex",  required_argument, NULL,               'c'   },
-  { "parse-stdin",        required_argument, NULL,               STDIN },
+  { "parse-stdin",        required_argument, NULL,        STDIN_OPTION },
   { "version",            no_argument,       NULL,               'V'   },
 
-#if CTAGS /* Ctags options */
+  /* ctags options */
   { "backward-search",    no_argument,       NULL,               'B'   },
   { "cxref",              no_argument,       NULL,               'x'   },
   { "defines",            no_argument,       NULL,               'd'   },
@@ -526,11 +521,15 @@ static struct option longopts[] =
   { "vgrind",             no_argument,       NULL,               'v'   },
   { "no-warn",            no_argument,       NULL,               'w'   },
 
-#else /* Etags options */
+  /* etags options */
   { "no-defines",         no_argument,       NULL,               'D'   },
   { "no-globals",         no_argument,       &globals,           0     },
   { "include",            required_argument, NULL,               'i'   },
-#endif
+  { "no-fallback-lang",   no_argument,       &fallback_lang,     0     },
+  { "fallback-lang",      no_argument,       &fallback_lang,     1     },
+  { "no-empty-file-entries", no_argument,    &empty_files,       0     },
+  { "empty-file-entries", no_argument,       &empty_files,       1     },
+
   { NULL }
 };
 
@@ -592,15 +591,17 @@ followed by a colon, are tags.";
    That is why default_C_entries is called for these. */
 static const char *default_C_suffixes [] =
   { "c", "h", NULL };
-#if CTAGS                              /* C help for Ctags */
-static const char default_C_help [] =
+
+/* C help for ctags */
+static const char ctags_default_C_help[] =
 "In C code, any C function is a tag.  Use -t to tag typedefs.\n\
 Use -T to tag definitions of 'struct', 'union' and 'enum'.\n\
 Use -d to tag '#define' macro definitions and 'enum' constants.\n\
 Use --globals to tag global variables.\n\
 You can tag function declarations and external variables by\n\
 using '--declarations', and struct members by using '--members'.";
-#else                                  /* C help for Etags */
+
+/* C help for etags */
 static const char default_C_help [] =
 "In C code, any C function or typedef is a tag, and so are\n\
 definitions of 'struct', 'union' and 'enum'.  '#define' macro\n\
@@ -611,7 +612,6 @@ definitions and 'enum' constants are tags unless you specify\n\
 '--no-members' can make the tags table file much smaller.\n\
 You can tag function declarations and external variables by\n\
 using '--declarations'.";
-#endif /* C help for Ctags and Etags */
 
 static const char *Cplusplus_suffixes [] =
   { "C", "c++", "cc", "cpp", "cxx", "H", "h++", "hh", "hpp", "hxx",
@@ -856,6 +856,7 @@ static language lang_names [] =
 {
   { "ada",       Ada_help,       Ada_funcs,         Ada_suffixes       },
   { "asm",       Asm_help,       Asm_labels,        Asm_suffixes       },
+#define C_LANG_NAMES_INDEX 2
   { "c",         default_C_help, default_C_entries, default_C_suffixes },
   { "c++",       Cplusplus_help, Cplusplus_entries, Cplusplus_suffixes },
   { "c*",        no_lang_help,   Cstar_entries,     Cstar_suffixes     },
@@ -928,15 +929,10 @@ For detailed help on a given language use, for example,\n\
 etags --help --lang=ada.");
 }
 
-#if CTAGS
-# define PROGRAM_NAME "ctags"
-#else
-# define PROGRAM_NAME "etags"
-#endif
 static _Noreturn void
 print_version (void)
 {
-  fputs ((PROGRAM_NAME " (" PACKAGE_NAME " " PACKAGE_VERSION ")\n"
+  fputs (("etags (" PACKAGE_NAME " " PACKAGE_VERSION ")\n"
          COPYRIGHT "\n"
          "This program is distributed under the terms in ETAGS.README\n"),
         stdout);
@@ -978,7 +974,7 @@ Relative ones are stored relative to the output file's directory.\n");
   puts ("--packages-only\n\
         For Ada files, only generate tags for packages.");
 
-  if (CTAGS)
+  if (ctags)
     puts ("-B, --backward-search\n\
         Write the search commands for the tag entries using '?', the\n\
         backward-search command instead of '/', the forward-search command.");
@@ -991,9 +987,13 @@ Relative ones are stored relative to the output file's directory.\n");
         Treat files whose name suffix defaults to C language as C++ files.");
   */
 
+  if (PRINT_UNDOCUMENTED_OPTIONS_HELP && !ctags)
+    puts ("--ctags\n\
+       Implement ctags behavior.");
+
   puts ("--declarations\n\
        In C and derived languages, create tags for function declarations,");
-  if (CTAGS)
+  if (ctags)
     puts ("\tand create tags for extern variables if --globals is used.");
   else
     puts
@@ -1002,7 +1002,7 @@ Relative ones are stored relative to the output file's directory.\n");
   puts ("\tIn Mercury, tag both declarations starting a line with ':-' and\n\
         first predicates or functions in clauses.");
 
-  if (CTAGS)
+  if (ctags)
     puts ("-d, --defines\n\
         Create tag entries for C #define constants and enum constants, too.");
   else
@@ -1010,7 +1010,7 @@ Relative ones are stored relative to the output file's directory.\n");
         Don't create tag entries for C #define constants and enum constants.\n\
        This makes the tags file smaller.");
 
-  if (!CTAGS)
+  if (!ctags)
     puts ("-i FILE, --include=FILE\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\
@@ -1020,7 +1020,7 @@ Relative ones are stored relative to the output file's directory.\n");
         Force the following files to be considered as written in the\n\
        named language up to the next --language=LANG option.");
 
-  if (CTAGS)
+  if (ctags)
     puts ("--globals\n\
        Create tag entries for global variables in some languages.");
   else
@@ -1031,7 +1031,7 @@ Relative ones are stored relative to the output file's directory.\n");
   puts ("--no-line-directive\n\
         Ignore #line preprocessor directives in C and derived languages.");
 
-  if (CTAGS)
+  if (ctags)
     puts ("--members\n\
        Create tag entries for members of structures in some languages.");
   else
@@ -1039,6 +1039,20 @@ Relative ones are stored relative to the output file's directory.\n");
        Do not create tag entries for members of structures\n\
        in some languages.");
 
+  if (!ctags)
+    {
+      puts ("--fallback-lang\n\
+       If a file's language could not be determined, try to parse\n\
+       it as Fortran and C/C++.");
+      puts ("--no-fallback-lang\n\
+       Do not fall back to Fortran and C/C++ if a file's language\n\
+       could not be determined.");
+      puts ("--empty-file-entries\n\
+       Produce file entries for files with no tags.");
+      puts ("--no-empty-file-entries\n\
+       Do not output file entries for files with no tags.");
+    }
+
   puts ("-Q, --class-qualify\n\
         Qualify tag names with their class name in C++, ObjC, Java, and Perl.\n\
         This produces tag names of the form \"class::member\" for C++,\n\
@@ -1072,7 +1086,7 @@ 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)
+  if (ctags)
     {
       puts ("-t, --typedefs\n\
         Generate tag entries for C and Ada typedefs.");
@@ -1081,7 +1095,7 @@ Relative ones are stored relative to the output file's directory.\n");
         and C++ member functions.");
     }
 
-  if (CTAGS)
+  if (ctags)
     puts ("-u, --update\n\
         Update the tag entries for the given files, leaving tag\n\
         entries for other files in place.  Currently, this is\n\
@@ -1090,7 +1104,7 @@ Relative ones are stored relative to the output file's directory.\n");
         tags file.  It is often faster to simply rebuild the entire\n\
         tag file than to use this.");
 
-  if (CTAGS)
+  if (ctags)
     {
       puts ("-v, --vgrind\n\
         Print on the standard output an index of items intended for\n\
@@ -1140,7 +1154,6 @@ main (int argc, char **argv)
   linebuffer filename_lb;
   bool help_asked = false;
   ptrdiff_t len;
-  char *optstring;
   int opt;
 
   progname = argv[0];
@@ -1163,9 +1176,7 @@ main (int argc, char **argv)
 
   /* 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 = concat ("-ac:Cf:Il:o:Qr:RSVhH",
-                     (CTAGS) ? "BxdtTuvw" : "Di:",
-                     "");
+  static char const optstring[] = "-aBc:CdDf:hHi:Il:o:Qr:RStTuvVwx";
 
   while ((opt = getopt_long (argc, argv, optstring, longopts, NULL)) != EOF)
     switch (opt)
@@ -1186,7 +1197,13 @@ main (int argc, char **argv)
        ++file_count;
        break;
 
-      case STDIN:
+      case CTAGS_OPTION:
+       /* Operate as ctags, not etags.  */
+       ctags = true;
+       lang_names[C_LANG_NAMES_INDEX].help = ctags_default_C_help;
+       break;
+
+      case STDIN_OPTION:
        /* Parse standard input.  Idea by Vivek <vivek@etla.org>. */
        argbuffer[current_arg].arg_type = at_stdin;
        argbuffer[current_arg].what     = optarg;
@@ -1296,7 +1313,7 @@ main (int argc, char **argv)
     }
 
   if (tagfile == NULL)
-    tagfile = savestr (CTAGS ? "tags" : "TAGS");
+    tagfile = savestr (ctags ? "tags" : "TAGS");
   cwd = etags_getcwd ();       /* the current working directory */
   if (cwd[strlen (cwd) - 1] != '/')
     {
@@ -1320,7 +1337,7 @@ main (int argc, char **argv)
   linebuffer_init (&filebuf);
   linebuffer_init (&token_name);
 
-  if (!CTAGS)
+  if (!ctags)
     {
       if (streq (tagfile, "-"))
        {
@@ -1378,13 +1395,13 @@ main (int argc, char **argv)
   free (filebuf.buffer);
   free (token_name.buffer);
 
-  if (!CTAGS || cxref_style)
+  if (!ctags || cxref_style)
     {
       /* Write the remaining tags to tagf (ETAGS) or stdout (CXREF). */
       put_entries (nodehead);
       free_tree (nodehead);
       nodehead = NULL;
-      if (!CTAGS)
+      if (!ctags)
        {
          fdesc *fdp;
 
@@ -1430,7 +1447,7 @@ main (int argc, char **argv)
   if (fclose (tagf) == EOF)
     pfatal (tagfile);
 
-  if (CTAGS)
+  if (ctags)
     if (append_to_tagfile || update)
       {
        /* Maybe these should be used:
@@ -1828,7 +1845,7 @@ process_file (FILE *fh, char *fn, language *lang)
   /* If not Ctags, and if this is not metasource and if it contained no #line
      directives, we can write the tags and free all nodes pointing to
      curfdp. */
-  if (!CTAGS
+  if (!ctags
       && curfdp->usecharno     /* no #line directives in this file */
       && !curfdp->lang->metasource)
     {
@@ -2052,7 +2069,7 @@ make_tag (const char *name,       /* tag name, or NULL if unnamed */
     fprintf (stderr, "%s on %s:%"PRIdMAX": %s\n",
             named ? name : "(unnamed)", curfdp->taggedfname, lno, linestart);
 
-  if (!CTAGS && named)         /* maybe set named to false */
+  if (!ctags && named)         /* maybe set named to false */
     /* Let's try to make an implicit tag name, that is, create an unnamed tag
        such that etags.el can guess a name from it. */
     {
@@ -2093,17 +2110,17 @@ pfnote (char *name,             /* tag name, or NULL if unnamed */
 {
   register node *np;
 
-  if ((CTAGS && name == NULL)
+  if ((ctags && name == NULL)
       /* We used to have an assertion here for the case below, but if we hit
         that case, it just means our parser got confused, and there's nothing
         to do about such empty "tags".  */
-      || (!CTAGS && name && name[0] == '\0'))
+      || (!ctags && name && name[0] == '\0'))
     return;
 
   np = xmalloc (sizeof *np);
 
   /* If ctags mode, change name "main" to M<thisfilename>. */
-  if (CTAGS && !cxref_style && streq (name, "main"))
+  if (ctags && !cxref_style && streq (name, "main"))
     {
       char *fp = strrchr (curfdp->taggedfname, '/');
       np->name = concat ("M", fp == NULL ? curfdp->taggedfname : fp + 1, "");
@@ -2128,7 +2145,7 @@ pfnote (char *name,               /* tag name, or NULL if unnamed */
   else
     np->cno = invalidcharno;
   np->left = np->right = NULL;
-  if (CTAGS && !cxref_style)
+  if (ctags && !cxref_style)
     {
       if (strnlen (linestart, 50) < 50)
        np->regex = concat (linestart, "$", "");
@@ -2255,7 +2272,7 @@ add_node (node *np, node **cur_node_p)
       return;
     }
 
-  if (!CTAGS)
+  if (!ctags)
     /* Etags Mode */
     {
       /* For each file name, tags are in a linked sublist on the right
@@ -2354,7 +2371,7 @@ invalidate_nodes (fdesc *badfdp, node **npp)
   node *np = *npp;
   stkentry *stack = NULL;
 
-  if (CTAGS)
+  if (ctags)
     {
       while (np)
        {
@@ -2464,7 +2481,7 @@ put_entry (node *np)
   /* Output this entry */
   if (np->valid)
     {
-      if (!CTAGS)
+      if (!ctags)
        {
          /* Etags mode */
          if (fdp != np->fdp)
@@ -2536,7 +2553,7 @@ put_entries (node *np)
   if (np == NULL)
     return;
 
-  if (CTAGS)
+  if (ctags)
     {
       while (np)
        {
index 14c8de3e7b4275ce3ae0167d6fe421a5cc766145..3edab77ab239a716f6e34adbde045aedb6771e41 100644 (file)
--- a/nt/README
+++ b/nt/README
@@ -44,7 +44,7 @@
   + addpm.exe - A basic installer that creates Start Menu icons for Emacs.
     Running this is optional.
 
-  + ctags.exe, etags.exe - Tools for generating tag files.  See the
+  + etags.exe - Tool for generating tag files.  See the
     `Tags' node of the Emacs manual.
 
   Several helper programs are installed in a version-specific
index 1ce76ebc3c13731dfe8e2f904c467c28478ced5f..800e851a22d48ce1a960ff0ee317070207b59a11 100644 (file)
@@ -104,7 +104,7 @@ See the end of the file for license conditions.
   + addpm.exe - A basic installer that adds Emacs to "Start" menus and
     adds Emacs-related entries to the Windows Registry.
 
-  + ctags.exe, etags.exe - Tools for generating tag files.  See the
+  + etags.exe - Tool for generating tag files.  See the
     `Tags' node of the Emacs manual.
 
   Several helper programs are in a version-specific subdirectory of
index cc6df35998d424dc29050b4ee82def6d38cabccb..7ea909314780787ef38b5095987fb95fe3f13848 100644 (file)
@@ -2167,14 +2167,10 @@ See `setenv' and `getenv'.  */);
   Vprocess_environment = Qnil;
 
   DEFVAR_LISP ("ctags-program-name", Vctags_program_name,
-    doc: /* Name of the `ctags' program distributed with Emacs.
+    doc: /* Name of the `ctags' program.
 Use this instead of calling `ctags' directly, as `ctags' may have been
 renamed to comply with executable naming restrictions on the system.  */);
-#if !defined HAVE_ANDROID || defined ANDROID_STUBIFY
   Vctags_program_name = build_string ("ctags");
-#else
-  Vctags_program_name = build_string ("libctags.so");
-#endif
 
   DEFVAR_LISP ("etags-program-name", Vetags_program_name,
     doc: /* Name of the `etags' program distributed with Emacs.