diff --git a/Tmain/input-encoding-option.d/tags-expected.txt b/Tmain/input-encoding-option.d/tags-expected.txt index 965a5be8a4..d172e2a9fc 100644 --- a/Tmain/input-encoding-option.d/tags-expected.txt +++ b/Tmain/input-encoding-option.d/tags-expected.txt @@ -1,6 +1,7 @@ !_TAG_FILE_ENCODING UTF-8 // -!_TAG_FILE_FORMAT 3 /extended format with meta character escaping/ +!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ +!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/ !_TAG_PROGRAM_AUTHOR Universal Ctags Team // !_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/ !_TAG_PROGRAM_URL https://ctags.io/ /official site/ diff --git a/Tmain/list-pseudo-tags.d/stdout-expected.txt b/Tmain/list-pseudo-tags.d/stdout-expected.txt index 5f20a3f3b8..ff3d81284f 100644 --- a/Tmain/list-pseudo-tags.d/stdout-expected.txt +++ b/Tmain/list-pseudo-tags.d/stdout-expected.txt @@ -4,6 +4,7 @@ TAG_FILE_FORMAT on the version of tags file format TAG_FILE_SORTED on how tags are sorted TAG_KIND_DESCRIPTION off the letters, names and descriptions of kinds in a parser TAG_KIND_SEPARATOR off the separators used in kinds +TAG_OUTPUT_MODE on the output mode: u-ctags or e-ctags TAG_PROGRAM_AUTHOR on the author of this ctags implementation TAG_PROGRAM_NAME on the name of this ctags implementation TAG_PROGRAM_URL on the official site URL of this ctags implementation diff --git a/Tmain/output-encoding-option.d/tags-expected.txt b/Tmain/output-encoding-option.d/tags-expected.txt index ac34b2ea2f..337bc3f728 100644 --- a/Tmain/output-encoding-option.d/tags-expected.txt +++ b/Tmain/output-encoding-option.d/tags-expected.txt @@ -1,6 +1,7 @@ !_TAG_FILE_ENCODING cp932 // -!_TAG_FILE_FORMAT 3 /extended format with meta character escaping/ +!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ +!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/ !_TAG_PROGRAM_AUTHOR Universal Ctags Team // !_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/ !_TAG_PROGRAM_URL https://ctags.io/ /official site/ diff --git a/Tmain/output-format-option.d/run.sh b/Tmain/output-format-option.d/run.sh index 6a2111b697..5d454292e3 100644 --- a/Tmain/output-format-option.d/run.sh +++ b/Tmain/output-format-option.d/run.sh @@ -5,6 +5,6 @@ CTAGS=$1 . ../utils.sh -run_with_format ctags +run_with_format u-ctags run_with_format etags run_with_format xref diff --git a/Tmain/output-format-option.d/stdout-expected.txt b/Tmain/output-format-option.d/stdout-expected.txt index 7adc374ce7..91462d4bfe 100644 --- a/Tmain/output-format-option.d/stdout-expected.txt +++ b/Tmain/output-format-option.d/stdout-expected.txt @@ -1,4 +1,4 @@ -# ctags +# u-ctags main input.c /^main(void)$/;" f typeref:typename:int # etags diff --git a/Tmain/output-input-field-with-no-escape.d/run.sh b/Tmain/output-input-field-with-no-escape.d/run.sh index e7f0ac063e..6ecb6f34ed 100644 --- a/Tmain/output-input-field-with-no-escape.d/run.sh +++ b/Tmain/output-input-field-with-no-escape.d/run.sh @@ -12,9 +12,9 @@ if ! ( echo '#define foo' > 'a\b.c' ) 2> /dev/null; then fi echo '# u-ctags' -${CTAGS} --options=NONE --pseudo-tags=TAG_FILE_FORMAT --extras=+p --format=3 -o - 'a\b.c' +${CTAGS} --options=NONE --pseudo-tags=TAG_OUTPUT_MODE --extras=+p --output-format=u-ctags -o - 'a\b.c' echo '# e-ctags' -${CTAGS} --options=NONE --pseudo-tags=TAG_FILE_FORMAT --extras=+p --format=2 -o - 'a\b.c' +${CTAGS} --options=NONE --pseudo-tags=TAG_OUTPUT_MODE --extras=+p --output-format=e-ctags -o - 'a\b.c' rm 'a\b.c' diff --git a/Tmain/output-input-field-with-no-escape.d/stdout-expected.txt b/Tmain/output-input-field-with-no-escape.d/stdout-expected.txt index 1a3188f098..0031c1b85a 100644 --- a/Tmain/output-input-field-with-no-escape.d/stdout-expected.txt +++ b/Tmain/output-input-field-with-no-escape.d/stdout-expected.txt @@ -1,6 +1,6 @@ # u-ctags -!_TAG_FILE_FORMAT 3 /extended format with meta character escaping/ +!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/ foo a\\b.c /^#define foo$/;" d file: # e-ctags -!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ +!_TAG_OUTPUT_MODE e-ctags /u-ctags or e-ctags/ foo a\b.c /^#define foo$/;" d file: diff --git a/Tmain/ptag-kind-desc.d/stdout-expected.txt b/Tmain/ptag-kind-desc.d/stdout-expected.txt index 1e3682c37e..623b82a3b9 100644 --- a/Tmain/ptag-kind-desc.d/stdout-expected.txt +++ b/Tmain/ptag-kind-desc.d/stdout-expected.txt @@ -1,17 +1,19 @@ # BUILTIN -!_TAG_FILE_FORMAT 3 /extended format with meta character escaping/ +!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ !_TAG_KIND_DESCRIPTION!Sh a,alias /aliases/ !_TAG_KIND_DESCRIPTION!Sh f,function /functions/ !_TAG_KIND_DESCRIPTION!Sh h,heredoc /label for here document/ !_TAG_KIND_DESCRIPTION!Sh s,script /script files/ +!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/ !_TAG_PROGRAM_AUTHOR Universal Ctags Team // !_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/ !_TAG_PROGRAM_URL https://ctags.io/ /official site/ # REGEX -!_TAG_FILE_FORMAT 3 /extended format with meta character escaping/ +!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ !_TAG_KIND_DESCRIPTION!foo k,kind /kinds/ +!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/ !_TAG_PROGRAM_AUTHOR Universal Ctags Team // !_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/ !_TAG_PROGRAM_URL https://ctags.io/ /official site/ diff --git a/Tmain/tags-pseudo-tags.d/stdout-expected.txt b/Tmain/tags-pseudo-tags.d/stdout-expected.txt index 2303087bcc..175f6c81a0 100644 --- a/Tmain/tags-pseudo-tags.d/stdout-expected.txt +++ b/Tmain/tags-pseudo-tags.d/stdout-expected.txt @@ -1,5 +1,5 @@ !_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/ -!_TAG_FILE_FORMAT 3 /extended format with meta character escaping/ +!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ !_TAG_KIND_SEPARATOR!PHP :: /*a/ !_TAG_KIND_SEPARATOR!PHP :: /*c/ @@ -19,6 +19,7 @@ !_TAG_KIND_SEPARATOR!PHP \\ /nn/ !_TAG_KIND_SEPARATOR!PHP \\ /nt/ !_TAG_KIND_SEPARATOR!PHP \\ /nv/ +!_TAG_OUTPUT_MODE u-ctags /u-ctags or e-ctags/ !_TAG_PROGRAM_AUTHOR Universal Ctags Team // !_TAG_PROGRAM_NAME Universal Ctags /Derived from Exuberant Ctags/ !_TAG_PROGRAM_URL https://ctags.io/ /official site/ diff --git a/Tmain/xref-ptag-in-list-extras.d/run.sh b/Tmain/xref-ptag-in-list-extras.d/run.sh index ff3425a36f..22a5f67a48 100644 --- a/Tmain/xref-ptag-in-list-extras.d/run.sh +++ b/Tmain/xref-ptag-in-list-extras.d/run.sh @@ -6,13 +6,13 @@ CTAGS=$1 O=/tmp/ctags-tmain-$$ echo '#' tags regular file -"${CTAGS}" --options=NONE --output-format=ctags -o $O --list-extras | grep pseudo +"${CTAGS}" --options=NONE --output-format=u-ctags -o $O --list-extras | grep pseudo echo '#' tags - -"${CTAGS}" --options=NONE --output-format=ctags -o - --list-extras | grep pseudo +"${CTAGS}" --options=NONE --output-format=u-ctags -o - --list-extras | grep pseudo echo '#' tags NOTHING -"${CTAGS}" --options=NONE --output-format=ctags --list-extras | grep pseudo +"${CTAGS}" --options=NONE --output-format=u-ctags --list-extras | grep pseudo echo '#' xref regular file "${CTAGS}" --options=NONE --output-format=xref -o $O --list-extras | grep pseudo diff --git a/Units/parser-php.r/php-full-qualified-tags-no-esc.d/args.ctags b/Units/parser-php.r/php-full-qualified-tags-no-esc.d/args.ctags index 0c3b92dc02..0dbae0c851 100644 --- a/Units/parser-php.r/php-full-qualified-tags-no-esc.d/args.ctags +++ b/Units/parser-php.r/php-full-qualified-tags-no-esc.d/args.ctags @@ -1,2 +1,4 @@ ---extras=+q ---format=2 +--extras=+qp +--output-format=e-ctags +--pseudo-tags=TAG_OUTPUT_MODE + diff --git a/Units/parser-php.r/php-full-qualified-tags-no-esc.d/expected.tags b/Units/parser-php.r/php-full-qualified-tags-no-esc.d/expected.tags index 3233a84d33..512138c60b 100644 --- a/Units/parser-php.r/php-full-qualified-tags-no-esc.d/expected.tags +++ b/Units/parser-php.r/php-full-qualified-tags-no-esc.d/expected.tags @@ -1,3 +1,4 @@ +!_TAG_OUTPUT_MODE e-ctags /u-ctags or e-ctags/ __construct input.php /^ public function __construct() {$/;" f class:foo\bar bar input.php /^class bar {$/;" c namespace:foo foo input.php /^namespace foo;$/;" n diff --git a/configure.ac b/configure.ac index 9a1721728a..183007aab8 100644 --- a/configure.ac +++ b/configure.ac @@ -54,9 +54,8 @@ AH_VERBATIM([DEFAULT_FILE_FORMAT], [ /* Define this as desired. * 1: Original ctags format * 2: Extended ctags format with extension flags in EX-style comment. - * 3: Use backslash for escaping meta characters like tab */ -#define DEFAULT_FILE_FORMAT 3 +#define DEFAULT_FILE_FORMAT 2 ]) AH_TEMPLATE([CASE_INSENSITIVE_FILENAMES], [Define this label if your system uses case-insensitive file names]) @@ -170,7 +169,7 @@ AC_ARG_ENABLE(etags, AC_ARG_ENABLE(extended-format, [AS_HELP_STRING([--disable-extended-format], [disable extension flags; use original ctags file format only])], - AC_DEFINE(DEFAULT_FILE_FORMAT, 1), AC_DEFINE(DEFAULT_FILE_FORMAT, 3)) + AC_DEFINE(DEFAULT_FILE_FORMAT, 1), AC_DEFINE(DEFAULT_FILE_FORMAT, 2)) AC_ARG_ENABLE(external-sort, [AS_HELP_STRING([--disable-external-sort], diff --git a/docs/format.rst b/docs/format.rst index 2f83f5b4cd..aec95fb053 100644 --- a/docs/format.rst +++ b/docs/format.rst @@ -485,10 +485,10 @@ Compatible output and weakness .. NOT REVIEWED YET -Default behavior (``--format=3`` option) has the -exceptions. In other hand, with ``--format=2`` option +Default behavior (``--output-format=u-ctags`` option) has the +exceptions. In other hand, with ``--output-format=e-ctags`` option ctags has no exception; Universal-ctags command may use the same file -format as Exuberant-ctags. However, ``--format=2`` throws +format as Exuberant-ctags. However, ``--output-format=e-ctags`` throws away a tag entry which name includes a space or a tab -character. ``TAG_FILE_FORMAT`` pseudo tag tells which format is +character. ``TAG_OUTPUT_MODE`` pseudo tag tells which format is used when ctags generating tags file. diff --git a/docs/news.rst b/docs/news.rst index 547d9fe713..613b7f27e1 100644 --- a/docs/news.rst +++ b/docs/news.rst @@ -921,23 +921,6 @@ Changes to the tags file format --------------------------------------------------------------------- - -version 3 format for handling meta characters in tag entry -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. REVIEWED - -To allow recording names including tab characters and other control -characters in a tag file, version 3 of the file format extends version -2 with extra escape sequences. - -You can use ``--format=2`` to keep compatibility with the output of -Exuberant-ctags; however, this version of the format cannot record -names which include tab characters. - -See also :ref:`Compatible output and weakness `. - - Truncating the pattern for long input lines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To prevent generating overly large tags files, a pattern field is @@ -1227,6 +1210,15 @@ The third line means `\\` is used when for combining a namespace item Of course, ctags uses the more specific line when choosing a separator; the third line has higher priority than the first. +``TAG_OUTPUT_MODE`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. NOT REVIEWED YET + +This pseudo tag represents output mode: u-ctags or e-ctags. + +See also :ref:`Compatible output and weakness `. + .. _parser-own-fields: Parser own fields diff --git a/main/entry.h b/main/entry.h index 70cc3cd1ce..ec3b774141 100644 --- a/main/entry.h +++ b/main/entry.h @@ -31,7 +31,6 @@ */ #define WHOLE_FILE -1L #define includeExtensionFlags() (Option.tagFileFormat > 1) -#define escapeMetacharacters() (Option.tagFileFormat > 2) /* * DATA DECLARATIONS diff --git a/main/field.c b/main/field.c index 39e34a3a59..9561cb7054 100644 --- a/main/field.c +++ b/main/field.c @@ -98,19 +98,21 @@ static fieldDefinition fieldDefinitionsFixed [] = { DEFINE_FIELD ('N', "name", true, "tag name", FIELDTYPE_STRING, - [WRITER_CTAGS] = renderFieldName, - [WRITER_JSON] = renderFieldNameNoEscape, + [WRITER_U_CTAGS] = renderFieldName, + [WRITER_E_CTAGS] = renderFieldNameNoEscape, + [WRITER_JSON] = renderFieldNameNoEscape, ), DEFINE_FIELD ('F', "input", true, "input file", FIELDTYPE_STRING, - [WRITER_CTAGS] = renderFieldInput, - [WRITER_JSON] = renderFieldInputNoEscape, + [WRITER_U_CTAGS] = renderFieldInput, + [WRITER_E_CTAGS] = renderFieldInputNoEscape, + [WRITER_JSON] = renderFieldInputNoEscape, ), DEFINE_FIELD ('P', "pattern", true, "pattern", FIELDTYPE_STRING|FIELDTYPE_BOOL, - [WRITER_CTAGS] = renderFieldPatternCtags, + [WRITER_U_CTAGS] = renderFieldPatternCtags, [WRITER_XREF] = renderFieldPatternCommon, [WRITER_JSON] = renderFieldPatternCommon, ), @@ -120,104 +122,106 @@ static fieldDefinition fieldDefinitionsExuberant [] = { DEFINE_FIELD ('C', "compact", false, "compact input line (used only in xref output)", FIELDTYPE_STRING, - [WRITER_CTAGS] = renderFieldCompactInputLine), + [WRITER_U_CTAGS] = renderFieldCompactInputLine), /* EXTENSION FIELDS */ DEFINE_FIELD_FULL ('a', "access", false, "Access (or export) of class members", isAccessFieldAvailable, FIELDTYPE_STRING, - [WRITER_CTAGS] = renderFieldAccess), + [WRITER_U_CTAGS] = renderFieldAccess), DEFINE_FIELD_FULL ('f', "file", true, "File-restricted scoping", isFileFieldAvailable, FIELDTYPE_BOOL, - [WRITER_CTAGS] = renderFieldFile), + [WRITER_U_CTAGS] = renderFieldFile), DEFINE_FIELD_FULL ('i', "inherits", false, "Inheritance information", isInheritsFieldAvailable, FIELDTYPE_STRING|FIELDTYPE_BOOL, - [WRITER_CTAGS] = renderFieldInherits), + [WRITER_U_CTAGS] = renderFieldInherits), DEFINE_FIELD ('K', NULL, false, "Kind of tag as full name", FIELDTYPE_STRING, - [WRITER_CTAGS] = renderFieldKindName), + [WRITER_U_CTAGS] = renderFieldKindName), DEFINE_FIELD ('k', NULL, true, "Kind of tag as a single letter", FIELDTYPE_STRING, - [WRITER_CTAGS] = renderFieldKindLetter), + [WRITER_U_CTAGS] = renderFieldKindLetter), DEFINE_FIELD_FULL ('l', "language", false, "Language of input file containing tag", isLanguageFieldAvailable, FIELDTYPE_STRING, - [WRITER_CTAGS] = renderFieldLanguage), + [WRITER_U_CTAGS] = renderFieldLanguage), DEFINE_FIELD_FULL ('m', "implementation", false, "Implementation information", isImplementationFieldAvailable, FIELDTYPE_STRING, - [WRITER_CTAGS] = renderFieldImplementation), + [WRITER_U_CTAGS] = renderFieldImplementation), DEFINE_FIELD ('n', "line", false, "Line number of tag definition", FIELDTYPE_INTEGER, - [WRITER_CTAGS] = renderFieldLineNumber), + [WRITER_U_CTAGS] = renderFieldLineNumber), DEFINE_FIELD_FULL ('S', "signature", false, "Signature of routine (e.g. prototype or parameter list)", isSignatureFieldAvailable, FIELDTYPE_STRING, - [WRITER_CTAGS] = renderFieldSignature), + [WRITER_U_CTAGS] = renderFieldSignature), DEFINE_FIELD ('s', NULL, true, "Scope of tag definition (`p' can be used for printing its kind)", FIELDTYPE_STRING, - [WRITER_CTAGS] = renderFieldScope, + [WRITER_U_CTAGS] = renderFieldScope, + [WRITER_E_CTAGS] = renderFieldScopeNoEscape, [WRITER_JSON] = renderFieldScopeNoEscape), DEFINE_FIELD_FULL ('t', "typeref", true, "Type and name of a variable or typedef", isTyperefFieldAvailable, FIELDTYPE_STRING, - [WRITER_CTAGS] = renderFieldTyperef), + [WRITER_U_CTAGS] = renderFieldTyperef), DEFINE_FIELD ('z', "kind", false, "Include the \"kind:\" key in kind field (use k or K) in tags output, kind full name in xref output", FIELDTYPE_STRING, /* Following renderer is for handling --_xformat=%{kind}; and is not for tags output. */ - [WRITER_CTAGS] = renderFieldKindName), + [WRITER_U_CTAGS] = renderFieldKindName), }; static fieldDefinition fieldDefinitionsUniversal [] = { DEFINE_FIELD ('r', "roles", false, "Roles", FIELDTYPE_STRING, - [WRITER_CTAGS] = renderFieldRoles), + [WRITER_U_CTAGS] = renderFieldRoles), DEFINE_FIELD ('R', NULL, false, "Marker (R or D) representing whether tag is definition or reference", FIELDTYPE_STRING, - [WRITER_CTAGS] = renderFieldRefMarker), + [WRITER_U_CTAGS] = renderFieldRefMarker), DEFINE_FIELD ('Z', "scope", false, "Include the \"scope:\" key in scope field (use s) in tags output, scope name in xref output", FIELDTYPE_STRING, /* Following renderer is for handling --_xformat=%{scope}; and is not for tags output. */ - [WRITER_CTAGS] = renderFieldScope, - [WRITER_JSON] = renderFieldScopeNoEscape), + [WRITER_U_CTAGS] = renderFieldScope, + [WRITER_E_CTAGS] = renderFieldScopeNoEscape, + [WRITER_JSON] = renderFieldScopeNoEscape), DEFINE_FIELD_FULL ('E', "extras", false, "Extra tag type information", isExtrasFieldAvailable, FIELDTYPE_STRING, - [WRITER_CTAGS] = renderFieldExtras), + [WRITER_U_CTAGS] = renderFieldExtras), DEFINE_FIELD_FULL ('x', "xpath", false, "xpath for the tag", isXpathFieldAvailable, FIELDTYPE_STRING, - [WRITER_CTAGS] = renderFieldXpath), + [WRITER_U_CTAGS] = renderFieldXpath), DEFINE_FIELD ('p', "scopeKind", false, "Kind of scope as full name", FIELDTYPE_STRING, - [WRITER_CTAGS] = renderFieldScopeKindName), + [WRITER_U_CTAGS] = renderFieldScopeKindName), DEFINE_FIELD_FULL ('e', "end", false, "end lines of various items", isEndFieldAvailable, FIELDTYPE_INTEGER, - [WRITER_CTAGS] = renderFieldEnd), + [WRITER_U_CTAGS] = renderFieldEnd), }; @@ -421,10 +425,7 @@ static const char *renderEscapedName (const bool isTagName, static const char *renderFieldName (const tagEntryInfo *const tag, const char *value CTAGS_ATTR_UNUSED, vString* b, bool *rejected CTAGS_ATTR_UNUSED) { - if (escapeMetacharacters()) - return renderEscapedName (true, tag->name, tag, b); - else - return renderFieldNameNoEscape(tag, value, b, rejected); + return renderEscapedName (true, tag->name, tag, b); } static const char *renderFieldNameNoEscape (const tagEntryInfo *const tag, const char *value CTAGS_ATTR_UNUSED, vString* b, @@ -441,17 +442,11 @@ static const char *renderFieldNameNoEscape (const tagEntryInfo *const tag, const static const char *renderFieldInput (const tagEntryInfo *const tag, const char *value CTAGS_ATTR_UNUSED, vString* b, bool *rejected CTAGS_ATTR_UNUSED) { + const char *f = tag->inputFileName; - if (escapeMetacharacters()) - { - const char *f = tag->inputFileName; - - if (Option.lineDirectives && tag->sourceFileName) - f = tag->sourceFileName; - return renderEscapedString (f, tag, b); - } - else - return renderFieldInputNoEscape(tag, value, b, rejected); + if (Option.lineDirectives && tag->sourceFileName) + f = tag->sourceFileName; + return renderEscapedString (f, tag, b); } static const char *renderFieldInputNoEscape (const tagEntryInfo *const tag, const char *value CTAGS_ATTR_UNUSED, vString* b, @@ -481,15 +476,10 @@ static const char *renderFieldSignature (const tagEntryInfo *const tag, const ch static const char *renderFieldScope (const tagEntryInfo *const tag, const char *value CTAGS_ATTR_UNUSED, vString* b, bool *rejected CTAGS_ATTR_UNUSED) { - if (escapeMetacharacters()) - { - const char* scope; + const char* scope; - getTagScopeInformation ((tagEntryInfo *const)tag, NULL, &scope); - return scope? renderEscapedName (false, scope, tag, b): NULL; - } - else - return renderFieldScopeNoEscape(tag, value, b, rejected); + getTagScopeInformation ((tagEntryInfo *const)tag, NULL, &scope); + return scope? renderEscapedName (false, scope, tag, b): NULL; } static const char *renderFieldScopeNoEscape (const tagEntryInfo *const tag, const char *value CTAGS_ATTR_UNUSED, vString* b, diff --git a/main/main.c b/main/main.c index 4df1741af5..a6fce7d754 100644 --- a/main/main.c +++ b/main/main.c @@ -651,7 +651,7 @@ extern int main (int argc CTAGS_ATTR_UNUSED, char **argv) setErrorPrinter (stderrDefaultErrorPrinter, NULL); setMainLoop (batchMakeTags, NULL); - setTagWriter (WRITER_CTAGS); + setTagWriter (WRITER_U_CTAGS); setCurrentDirectory (); setExecutableName (*argv++); diff --git a/main/options.c b/main/options.c index 8386553dd9..decda59795 100644 --- a/main/options.c +++ b/main/options.c @@ -60,7 +60,7 @@ #define IGNORE_SEPARATORS ", \t\n" #ifndef DEFAULT_FILE_FORMAT -# define DEFAULT_FILE_FORMAT 3 +# define DEFAULT_FILE_FORMAT 2 #endif #if defined (HAVE_OPENDIR) || defined (HAVE__FINDFIRST) @@ -85,7 +85,7 @@ enum eOptionLimits { MaxHeaderExtensions = 100, /* maximum number of extensions in -h option */ - MaxSupportedTagFormat = 3 + MaxSupportedTagFormat = 2 }; typedef struct sOptionDescription { @@ -263,7 +263,11 @@ static optionDescription LongOptionDescription [] = { {1," Specify string to print to stdout following the tags for each file"}, {1," parsed when --filter is enabled."}, {0," --format=level"}, - {0," Force output of specified tag file format [" STRINGIFY(DEFAULT_FILE_FORMAT) "]."}, +#if DEFAULT_FILE_FORMAT == 1 + {0," Force output of specified tag file format [1]."}, +#else + {0," Force output of specified tag file format [2]."}, +#endif {1," --guess-language-eagerly"}, {1," Guess the language of input file more eagerly"}, {1," (but taking longer time for guessing):"}, @@ -370,12 +374,12 @@ static optionDescription LongOptionDescription [] = { {1," The encoding to write the tag file in. Defaults to UTF-8 if --input-encoding"}, {1," is specified, otherwise no conversion is performed."}, #endif - {0," --output-format=ctags|etags|xref" + {0," --output-format=u-ctags|e-ctags|etags|xref" #ifdef HAVE_JANSSON "|json" #endif }, - {0," Specify the output format. [ctags]"}, + {0," Specify the output format. [u-ctags]"}, {1," --param-:name=argument"}, {1," Set specific parameter. Available parameters can be listed with --list-params."}, {0," --pattern-length-limit=N"}, @@ -797,6 +801,7 @@ static void setXrefMode (void) static void setJsonMode (void) { enablePtag (PTAG_JSON_OUTPUT_VERSION, true); + enablePtag (PTAG_OUTPUT_MODE, false); enablePtag (PTAG_FILE_FORMAT, false); setTagWriter (WRITER_JSON); } @@ -2266,8 +2271,10 @@ static void processOutputFormat (const char *const option CTAGS_ATTR_UNUSED, if (parameter [0] == '\0') error (FATAL, "no output format name supplied for \"%s\"", option); - if (strcmp (parameter, "ctags") == 0) - setTagWriter (WRITER_CTAGS); + if (strcmp (parameter, "u-ctags") == 0) + ; + else if (strcmp (parameter, "e-ctags") == 0) + setTagWriter (WRITER_E_CTAGS); else if (strcmp (parameter, "etags") == 0) setEtagsMode (); else if (strcmp (parameter, "xref") == 0) diff --git a/main/ptag.c b/main/ptag.c index e962cf465a..aaa88154f0 100644 --- a/main/ptag.c +++ b/main/ptag.c @@ -34,9 +34,6 @@ static bool ptagMakeFormat (ptagDesc *desc, void *data CTAGS_ATTR_UNUSED) else if (Option.tagFileFormat == 2) formatComment = "extended format; --format=1 will not append ;\" to lines"; - else if (Option.tagFileFormat == 3) - formatComment = - "extended format with meta character escaping"; return writePseudoTag (desc, format, formatComment, NULL); } @@ -142,6 +139,10 @@ static ptagDesc ptagDescs [] = { "the letters, names and descriptions of kinds in a parser", ptagMakeKindDescriptions, false }, + { true, "TAG_OUTPUT_MODE", + "the output mode: u-ctags or e-ctags", + ptagMakeCtagsOutputMode, + true }, }; extern bool makePtagIfEnabled (ptagType type, void *data) diff --git a/main/ptag.h b/main/ptag.h index e9f7d142fb..7266553c44 100644 --- a/main/ptag.h +++ b/main/ptag.h @@ -35,6 +35,7 @@ typedef enum ePtagType { /* pseudo tag content control */ #endif PTAG_KIND_SEPARATOR, PTAG_KIND_DESCRIPTION, + PTAG_OUTPUT_MODE, PTAG_COUNT } ptagType; diff --git a/main/writer-ctags.c b/main/writer-ctags.c index 67d719d3e3..bea68f75ea 100644 --- a/main/writer-ctags.c +++ b/main/writer-ctags.c @@ -34,31 +34,31 @@ struct rejection { bool rejectedInThisInput; }; +tagWriter uCtagsWriter = { + .writeEntry = writeCtagsEntry, + .writePtagEntry = writeCtagsPtagEntry, + .preWriteEntry = NULL, + .postWriteEntry = NULL, + .buildFqTagCache = buildCtagsFqTagCache, + .defaultFileName = CTAGS_FILE, +}; + static void *beginECtagsFile (tagWriter *writer CTAGS_ATTR_UNUSED, MIO * mio CTAGS_ATTR_UNUSED) { static struct rejection rej; - if (escapeMetacharacters()) - return NULL; - else - { - rej.rejectedInThisInput = false; - return &rej; - } + rej.rejectedInThisInput = false; + + return &rej; } static bool endECTagsFile (tagWriter *writer, MIO * mio CTAGS_ATTR_UNUSED, const char* filename CTAGS_ATTR_UNUSED) { - if (escapeMetacharacters()) - return false; - else - { - struct rejection *rej = writer->private; - return rej->rejectedInThisInput; - } + struct rejection *rej = writer->private; + return rej->rejectedInThisInput; } -tagWriter ctagsWriter = { +tagWriter eCtagsWriter = { .writeEntry = writeCtagsEntry, .writePtagEntry = writeCtagsPtagEntry, .preWriteEntry = beginECtagsFile, diff --git a/main/writer.c b/main/writer.c index f3b89fcf47..84b24dda25 100644 --- a/main/writer.c +++ b/main/writer.c @@ -11,14 +11,15 @@ #include "entry.h" #include "writer.h" -extern tagWriter ctagsWriter; +extern tagWriter uCtagsWriter; extern tagWriter eCtagsWriter; extern tagWriter etagsWriter; extern tagWriter xrefWriter; extern tagWriter jsonWriter; static tagWriter *writerTable [WRITER_COUNT] = { - [WRITER_CTAGS] = &ctagsWriter, + [WRITER_U_CTAGS] = &uCtagsWriter, + [WRITER_E_CTAGS] = &eCtagsWriter, [WRITER_ETAGS] = &etagsWriter, [WRITER_XREF] = &xrefWriter, [WRITER_JSON] = &jsonWriter, @@ -77,6 +78,22 @@ extern void writerBuildFqTagCache (tagEntryInfo *const tag) writer->buildFqTagCache (writer, tag); } + +extern bool ptagMakeCtagsOutputMode (ptagDesc *desc, void *data CTAGS_ATTR_UNUSED) +{ + const char *mode =""; + + if (&uCtagsWriter == writer) + mode = "u-ctags"; + else if (&eCtagsWriter == writer) + mode = "e-ctags"; + + return writePseudoTag (desc, + mode, + "u-ctags or e-ctags", + NULL); +} + extern const char *outputDefaultFileName (void) { return writer->defaultFileName; diff --git a/main/writer.h b/main/writer.h index 5b6b6e7d9a..bb295d40e9 100644 --- a/main/writer.h +++ b/main/writer.h @@ -20,7 +20,8 @@ typedef enum eWriterType { WRITER_DEFAULT, - WRITER_CTAGS = WRITER_DEFAULT, + WRITER_U_CTAGS = WRITER_DEFAULT, + WRITER_E_CTAGS, WRITER_ETAGS, WRITER_XREF, WRITER_JSON, @@ -70,6 +71,7 @@ extern void truncateTagLineAfterTag (char *const line, const char *const token, extern void abort_if_ferror(MIO *const fp); extern bool ptagMakeJsonOutputVersion (ptagDesc *desc, void *data CTAGS_ATTR_UNUSED); +extern bool ptagMakeCtagsOutputMode (ptagDesc *desc, void *data CTAGS_ATTR_UNUSED); extern bool writerCanPrintPtag (void);