ctags/etags-gnuctags-allow-duplicates.diff

91 lines
3.2 KiB
Diff

--- etags.1
+++ etags.1
@@ -26,12 +26,12 @@
[\|\-\-help\|] [\|\-\-version\|]
\fIfile\fP .\|.\|.
-\fBgnuctags\fP [\|\-aCdgIRVh\|] [\|\-BtTuvwx\|] [\|\-l \fIlanguage\fP\|]
+\fBgnuctags\fP [\|\-aCdgIRVh\|] [\|\-ABtTuvwx\|] [\|\-l \fIlanguage\fP\|]
.if n .br
[\|\-o \fItagfile\fP\|] [\|\-r \fIregexp\fP\|]
[\|\-\-parse\-stdin=\fIfile\fP\|]
.br
-[\|\-\-append\|] [\|\-\-backward\-search\|]
+[\|\-\-allow\-duplicates\|] [\|\-\-append\|] [\|\-\-backward\-search\|]
[\|\-\-cxref\|] [\|\-\-defines\|] [\|\-\-forward\-search\|]
[\|\-\-globals\|] [\|\-\-ignore\-indentation\|]
[\|\-\-language=\fIlanguage\fP\|] [\|\-\-members\|]
@@ -75,6 +75,12 @@
\fBetags\fP does not recognize them.
The programs accept unambiguous abbreviations for long option names.
.TP
+.B \-A, \-\-allow\-duplicates
+Create entries for duplicate tags. Some editors accept tags files with
+entries for duplicate tags.
+Since this is the default behavior of \fBetags\fP, only \fBgnuctags\fP
+accepts this option.
+.TP
.B \-a, \-\-append
Append to existing tag file. (For \fBvi\fP-format tag files, see also
\fB\-\-update\fP.)
--- etags.c
+++ etags.c
@@ -444,6 +444,7 @@
*midtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789";
static bool append_to_tagfile; /* -a: append to tags */
+static bool allow_duplicates; /* -A: allow duplicate tags */
/* The next four default to TRUE for etags, but to FALSE for ctags. */
static bool typedefs; /* -t: create tags for C and Ada typedefs */
static bool typedefs_or_cplusplus; /* -T: create tags for C typedefs, level */
@@ -496,6 +497,7 @@
{ "version", no_argument, NULL, 'V' },
#if CTAGS /* Ctags options */
+ { "allow-duplicates", no_argument, NULL, 'A' },
{ "backward-search", no_argument, NULL, 'B' },
{ "cxref", no_argument, NULL, 'x' },
{ "defines", no_argument, NULL, 'd' },
@@ -875,6 +877,12 @@
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, --allow-duplicates\n\
+ Allow duplicate tag entries.");
+ }
+
puts ("-a, --append\n\
Append tag entries to existing tags file.");
@@ -1175,7 +1183,7 @@
non-options arguments to be at the end, but leaves them alone. */
optstring = concat (NO_LONG_OPTIONS ? "" : "-",
"ac:Cf:Il:o:r:RSVhH",
- (CTAGS) ? "BxdtTuvw" : "Di:");
+ (CTAGS) ? "ABxdtTuvw" : "Di:");
while ((opt = getopt_long (argc, argv, optstring, longopts, NULL)) != EOF)
switch (opt)
@@ -1259,6 +1267,7 @@
case 'i': included_files[nincluded_files++] = optarg; break;
/* Ctags options. */
+ case 'A': allow_duplicates = TRUE; break;
case 'B': searchar = '?'; break;
case 'd': constantypedefs = TRUE; break;
case 't': typedefs = TRUE; break;
@@ -2167,8 +2176,10 @@
/*
* If this tag name matches an existing one, then
* do not add the node, but maybe print a warning.
+ * If duplicates are allowed, continue looking for
+ * a node with a branch where we can insert this node.
*/
- if (!dif)
+ if (!allow_duplicates && !dif)
{
if (np->fdp == cur_node->fdp)
{