From 50d42e2056e85c72932f882f6a310762e0d0e8d5 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Wed, 14 Dec 2022 15:45:27 +0900 Subject: [PATCH 1/7] Tmain: delete version numbers printed by test cases The original code forbided ctags printng the version numbers. This change allows printing them but deleteing them after printing. Signed-off-by: Masatake YAMATO --- Tmain/interactive-mode.d/run.sh | 17 ++++++++--------- Tmain/interactive-notice-output.d/run.sh | 2 +- Tmain/interactive-option-write-to-file.d/run.sh | 5 ++--- Tmain/sandbox-crash.d/run.sh | 9 +++++---- Tmain/sandbox-default-req.d/run.sh | 9 +++++---- Tmain/sandbox-no-eager-guessing.d/run.sh | 9 +++++---- Tmain/sandbox-with-eager-guessing.d/run.sh | 9 +++++---- Tmain/sandbox.d/run.sh | 9 +++++---- Tmain/utils.sh | 5 +++++ 9 files changed, 41 insertions(+), 33 deletions(-) diff --git a/Tmain/interactive-mode.d/run.sh b/Tmain/interactive-mode.d/run.sh index 96f806b791..00b25ebadf 100644 --- a/Tmain/interactive-mode.d/run.sh +++ b/Tmain/interactive-mode.d/run.sh @@ -9,35 +9,34 @@ is_feature_available ${CTAGS} interactive # It seems that the output format is slightly different between libjansson versions s() { - sed -e s/':"'/': "'/g + sed -e s/':"'/': "'/g | jdropver } CTAGS="$CTAGS --options=NONE" -NV="--pseudo-tags=-TAG_PROGRAM_VERSION" echo identification message on startup echo ======================================= -${CTAGS} --_interactive $NV < /dev/null |s +${CTAGS} --_interactive < /dev/null |s echo echo error on invalid command echo ======================================= -echo '{"command":"foobar"}' | ${CTAGS} --_interactive $NV |s +echo '{"command":"foobar"}' | ${CTAGS} --_interactive |s echo echo error on missing arguments echo ======================================= -echo '{"command":"generate-tags"}' | ${CTAGS} --_interactive $NV |s +echo '{"command":"generate-tags"}' | ${CTAGS} --_interactive |s echo echo error on invalid file echo ======================================= -echo '{"command":"generate-tags", "filename":"test.foo"}' | ${CTAGS} --_interactive $NV |s +echo '{"command":"generate-tags", "filename":"test.foo"}' | ${CTAGS} --_interactive |s echo echo generate tags from file echo ======================================= -echo '{"command":"generate-tags", "filename":"test.rb"}' | ${CTAGS} --_interactive $NV |s +echo '{"command":"generate-tags", "filename":"test.rb"}' | ${CTAGS} --_interactive |s echo echo process multiple commands @@ -45,7 +44,7 @@ echo ======================================= ( echo '{"command":"generate-tags", "filename":"test.rb"}' echo '{"command":"generate-tags", "filename":"test.c"}' -) | ${CTAGS} --_interactive $NV |s +) | ${CTAGS} --_interactive |s echo echo generate tags from data @@ -54,4 +53,4 @@ size=$(filesize test.rb) ( echo '{"command":"generate-tags", "filename":"foobar.rb", "size":'$size'}' cat test.rb -) | ${CTAGS} --_interactive $NV |s +) | ${CTAGS} --_interactive |s diff --git a/Tmain/interactive-notice-output.d/run.sh b/Tmain/interactive-notice-output.d/run.sh index f2f50f11db..77ff50bfcc 100644 --- a/Tmain/interactive-notice-output.d/run.sh +++ b/Tmain/interactive-notice-output.d/run.sh @@ -8,7 +8,7 @@ CTAGS=$1 # It seems that the output format is slightly different between libjansson versions s() { - sed -e s/':"'/': "'/g + sed -e s/':"'/': "'/g | jdropver } if is_feature_available ${CTAGS} json; then diff --git a/Tmain/interactive-option-write-to-file.d/run.sh b/Tmain/interactive-option-write-to-file.d/run.sh index d21a290e81..78aa365ce8 100644 --- a/Tmain/interactive-option-write-to-file.d/run.sh +++ b/Tmain/interactive-option-write-to-file.d/run.sh @@ -11,12 +11,11 @@ is_feature_available ${CTAGS} interactive # It seems that the output format is slightly different between libjansson versions s() { - sed -e s/':"'/': "'/g + sed -e s/':"'/': "'/g | jdropver } O=/tmp/ctags-tmain-$$.txt -echo '{"command":"generate-tags", "filename":"test.rb"}' | ${CTAGS} --quiet --options=NONE --_interactive -o ${O} \ - --pseudo-tags=-TAG_PROGRAM_VERSION |s +echo '{"command":"generate-tags", "filename":"test.rb"}' | ${CTAGS} --quiet --options=NONE --_interactive -o ${O} |s rm -f ${O} diff --git a/Tmain/sandbox-crash.d/run.sh b/Tmain/sandbox-crash.d/run.sh index 132bbd3545..1baf93b094 100644 --- a/Tmain/sandbox-crash.d/run.sh +++ b/Tmain/sandbox-crash.d/run.sh @@ -14,7 +14,8 @@ is_feature_available ${CTAGS} '!' gcov { echo '{"command":"generate-tags", "filename":"input.ctst", "size": 1}' echo 'P' -} | $CTAGS --quiet --options=NONE --language-force=CTagsSelfTest --_interactive=sandbox \ - --pseudo-tags=-TAG_PROGRAM_VERSION - -exit $? +} | $CTAGS --quiet --options=NONE --language-force=CTagsSelfTest --_interactive=sandbox > /tmp/ctags-Tmain-$$ +r=$? +jdropver < /tmp/ctags-Tmain-$$ +rm /tmp/ctags-Tmain-$$ +exit $r diff --git a/Tmain/sandbox-default-req.d/run.sh b/Tmain/sandbox-default-req.d/run.sh index 2a6846fc59..3e2322679b 100644 --- a/Tmain/sandbox-default-req.d/run.sh +++ b/Tmain/sandbox-default-req.d/run.sh @@ -14,7 +14,8 @@ is_feature_available ${CTAGS} '!' gcov echo '{"command":"generate-tags", "filename":"input.c", "size": -1}' echo '{"command":"generate-tags", "filename":"input.el", "size": 16}' echo '(defun foo () 0)' -} | $CTAGS --quiet --options=NONE --_interactive=sandbox \ - --pseudo-tags=-TAG_PROGRAM_VERSION - -exit $? +} | $CTAGS --quiet --options=NONE --_interactive=sandbox > /tmp/ctags-Tmain-$$ +r=$? +jdropver < /tmp/ctags-Tmain-$$ +rm /tmp/ctags-Tmain-$$ +exit $r diff --git a/Tmain/sandbox-no-eager-guessing.d/run.sh b/Tmain/sandbox-no-eager-guessing.d/run.sh index 30fa44b2c9..2183eef7ae 100644 --- a/Tmain/sandbox-no-eager-guessing.d/run.sh +++ b/Tmain/sandbox-no-eager-guessing.d/run.sh @@ -13,7 +13,8 @@ is_feature_available ${CTAGS} '!' gcov { echo '{"command":"generate-tags", "filename":"input.unknown", "size": 44}' echo '/* -*- c -*- */ int main(void) { return 0; }' -} | $CTAGS --quiet --options=NONE --_interactive=sandbox \ - --pseudo-tags=-TAG_PROGRAM_VERSION - -exit $? +} | $CTAGS --quiet --options=NONE --_interactive=sandbox > /tmp/ctags-Tmain-$$ +r=$? +jdropver < /tmp/ctags-Tmain-$$ +rm /tmp/ctags-Tmain-$$ +exit $r diff --git a/Tmain/sandbox-with-eager-guessing.d/run.sh b/Tmain/sandbox-with-eager-guessing.d/run.sh index b2bd3ccb4f..4699aebbcd 100644 --- a/Tmain/sandbox-with-eager-guessing.d/run.sh +++ b/Tmain/sandbox-with-eager-guessing.d/run.sh @@ -13,7 +13,8 @@ is_feature_available ${CTAGS} '!' gcov { echo '{"command":"generate-tags", "filename":"input.unknown", "size": 44}' echo '/* -*- c -*- */ int main(void) { return 0; }' -} | $CTAGS --quiet --options=NONE -G --_interactive=sandbox \ - --pseudo-tags=-TAG_PROGRAM_VERSION - -exit $? +} | $CTAGS --quiet --options=NONE -G --_interactive=sandbox > /tmp/ctags-Tmain-$$ +r=$? +jdropver < /tmp/ctags-Tmain-$$ +rm /tmp/ctags-Tmain-$$ +exit $r diff --git a/Tmain/sandbox.d/run.sh b/Tmain/sandbox.d/run.sh index 4280433a62..717362e7d4 100644 --- a/Tmain/sandbox.d/run.sh +++ b/Tmain/sandbox.d/run.sh @@ -13,7 +13,8 @@ is_feature_available ${CTAGS} '!' gcov { echo '{"command":"generate-tags", "filename":"input.c", "size": 28}' echo 'int main(void) { return 0; }' -} | $CTAGS --quiet --options=NONE --_interactive=sandbox \ - --pseudo-tags=-TAG_PROGRAM_VERSION - -exit $? +} | $CTAGS --quiet --options=NONE --_interactive=sandbox > /tmp/ctags-Tmain-$$ +r=$? +jdropver < /tmp/ctags-Tmain-$$ +rm /tmp/ctags-Tmain-$$ +exit $r diff --git a/Tmain/utils.sh b/Tmain/utils.sh index c2927cef89..57567bc63f 100644 --- a/Tmain/utils.sh +++ b/Tmain/utils.sh @@ -143,3 +143,8 @@ check_encoding() fi skip "iconv doesn't know about the encoding: $1" } + +jdropver() +{ + sed -e 's/, "version": "5.9.0"//' +} From da7492667c2329f552b579f24de43ca2c3760fd7 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Wed, 14 Dec 2022 14:24:33 +0900 Subject: [PATCH 2/7] json-writer: revert "main: provide the way to hide version number from interactive output" This reverts commit fc28b8fcef927f66b42dbdffd798092314673c0c. I didn't understand that the json-writer should print `"{\"_type\": \"program\"...' always. --- Tmain/sandbox-version.d/exit-expected.txt | 1 - Tmain/sandbox-version.d/run.sh | 22 --------------------- Tmain/sandbox-version.d/stderr-expected.txt | 0 Tmain/sandbox-version.d/stdout-expected.txt | 3 --- main/main.c | 12 +---------- 5 files changed, 1 insertion(+), 37 deletions(-) delete mode 100644 Tmain/sandbox-version.d/exit-expected.txt delete mode 100644 Tmain/sandbox-version.d/run.sh delete mode 100644 Tmain/sandbox-version.d/stderr-expected.txt delete mode 100644 Tmain/sandbox-version.d/stdout-expected.txt diff --git a/Tmain/sandbox-version.d/exit-expected.txt b/Tmain/sandbox-version.d/exit-expected.txt deleted file mode 100644 index 573541ac97..0000000000 --- a/Tmain/sandbox-version.d/exit-expected.txt +++ /dev/null @@ -1 +0,0 @@ -0 diff --git a/Tmain/sandbox-version.d/run.sh b/Tmain/sandbox-version.d/run.sh deleted file mode 100644 index 23d7a47f25..0000000000 --- a/Tmain/sandbox-version.d/run.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -# Copyright: 2022 Masatake YAMATO -# License: GPL-2 - -CTAGS=$1 - -. ../utils.sh -is_feature_available $CTAGS sandbox -is_feature_available ${CTAGS} interactive -is_feature_available ${CTAGS} '!' gcov - -echo | $CTAGS --quiet --options=NONE --_interactive=sandbox \ - --pseudo-tags=+TAG_PROGRAM_NAME \ - --pseudo-tags=+TAG_PROGRAM_VERSION && -echo | $CTAGS --quiet --options=NONE --_interactive=sandbox \ - --pseudo-tags=-TAG_PROGRAM_NAME \ - --pseudo-tags=+TAG_PROGRAM_VERSION && -echo | $CTAGS --quiet --options=NONE --_interactive=sandbox \ - --pseudo-tags=+TAG_PROGRAM_NAME \ - --pseudo-tags=-TAG_PROGRAM_VERSION -exit $? diff --git a/Tmain/sandbox-version.d/stderr-expected.txt b/Tmain/sandbox-version.d/stderr-expected.txt deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/Tmain/sandbox-version.d/stdout-expected.txt b/Tmain/sandbox-version.d/stdout-expected.txt deleted file mode 100644 index bb8f3e9639..0000000000 --- a/Tmain/sandbox-version.d/stdout-expected.txt +++ /dev/null @@ -1,3 +0,0 @@ -{"_type": "program", "name": "Universal Ctags", "version": "5.9.0"} -{"_type": "program", "version": "5.9.0"} -{"_type": "program", "name": "Universal Ctags"} diff --git a/main/main.c b/main/main.c index 7c4e77d736..6536a21616 100644 --- a/main/main.c +++ b/main/main.c @@ -59,7 +59,6 @@ #include "options_p.h" #include "optscript.h" #include "parse_p.h" -#include "ptag_p.h" #include "read_p.h" #include "routines_p.h" #include "stats_p.h" @@ -416,16 +415,7 @@ void interactiveLoop (cookedArgs *args CTAGS_ATTR_UNUSED, void *user) char buffer[1024]; json_t *request; - if (isPtagEnabled(PTAG_PROGRAM_NAME)) - { - if (isPtagEnabled(PTAG_PROGRAM_VERSION)) - fputs ("{\"_type\": \"program\", \"name\": \"" PROGRAM_NAME "\", \"version\": \"" PROGRAM_VERSION "\"}\n", stdout); - else - fputs ("{\"_type\": \"program\", \"name\": \"" PROGRAM_NAME "\"}\n", stdout); - } - else if (isPtagEnabled(PTAG_PROGRAM_VERSION)) - fputs ("{\"_type\": \"program\", \"version\": \"" PROGRAM_VERSION "\"}\n", stdout); - + fputs ("{\"_type\": \"program\", \"name\": \"" PROGRAM_NAME "\", \"version\": \"" PROGRAM_VERSION "\"}\n", stdout); fflush (stdout); while (fgets (buffer, sizeof(buffer), stdin)) From 20a0373e69440c20f597d1a7a6c5b2ed47aef1a7 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Wed, 14 Dec 2022 14:19:15 +0900 Subject: [PATCH 3/7] docs(man): fix a typo Signed-off-by: Masatake YAMATO --- docs/man/ctags-json-output.5.rst | 2 +- man/ctags-json-output.5.rst.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/man/ctags-json-output.5.rst b/docs/man/ctags-json-output.5.rst index c6519c216e..74dcbb859d 100644 --- a/docs/man/ctags-json-output.5.rst +++ b/docs/man/ctags-json-output.5.rst @@ -95,7 +95,7 @@ For an example, the value for ``pattern`` field of ctags takes a string or a boo VERSIONS -------- -Cnages since "0.0" +Change since "0.0" ~~~~~~~~~~~~~~~~~~ * New key ``kindName`` for ``TAG_ROLE_DESCRIPTION`` pseudo tag diff --git a/man/ctags-json-output.5.rst.in b/man/ctags-json-output.5.rst.in index cbb41fa55e..4f72cc51a3 100644 --- a/man/ctags-json-output.5.rst.in +++ b/man/ctags-json-output.5.rst.in @@ -95,7 +95,7 @@ For an example, the value for ``pattern`` field of ctags takes a string or a boo VERSIONS -------- -Cnages since "0.0" +Change since "0.0" ~~~~~~~~~~~~~~~~~~ * New key ``kindName`` for ``TAG_ROLE_DESCRIPTION`` pseudo tag From 454fb4a32c1bb6647b21a8a561e6c4c4605d96e0 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Wed, 14 Dec 2022 14:33:57 +0900 Subject: [PATCH 4/7] Tmain: adjust indentation Signed-off-by: Masatake YAMATO --- Tmain/output-encoding-option.d/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tmain/output-encoding-option.d/run.sh b/Tmain/output-encoding-option.d/run.sh index ca49229355..dcbf3b55c5 100644 --- a/Tmain/output-encoding-option.d/run.sh +++ b/Tmain/output-encoding-option.d/run.sh @@ -13,7 +13,7 @@ if ${CTAGS} --quiet --options=NONE --list-features | grep -q iconv; then check_encoding euc-jp if ${CTAGS} --quiet --options=NONE \ --pseudo-tags=-TAG_PROC_CWD \ - --pseudo-tags=-TAG_PROGRAM_VERSION \ + --pseudo-tags=-TAG_PROGRAM_VERSION \ --pseudo-tags=-TAG_KIND_DESCRIPTION \ --pseudo-tags=-TAG_FIELD_DESCRIPTION \ --pseudo-tags=-TAG_EXTRA_DESCRIPTION \ From 7930f3ebd813f31867f3f448baf536efa0c1bdd8 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Wed, 14 Dec 2022 00:50:59 +0900 Subject: [PATCH 5/7] main,comment: fix typos --- main/ctags.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main/ctags.h b/main/ctags.h index c063e3d66c..cfaa3d9fa6 100644 --- a/main/ctags.h +++ b/main/ctags.h @@ -21,7 +21,7 @@ of ctags or readtags commands, increment VERSION. Removing a parameter of a parser is part of incompatible change for the CLI. - When OUTPUT_VERSOIN_AGE set to 0, increment VERSION. Set REVISION + When OUTPUT_VERSION_AGE set to 0, increment VERSION. Set REVISION and PATCH to 0. For changing setting versionAge member of a parser, increment VERSION. Set REVISION and PATCH to 0. @@ -30,8 +30,8 @@ For uppper compatible changes for the CLI, increment REVISION. Adding a new parameter to a parser is an uppper compatible change. - When incrementing OUTPUT_VERSOIN_CURRENT but not setting - OUTPUT_VERSOIN_AGE to 0, increment REVISION. + When incrementing OUTPUT_VERSION_CURRENT but not setting + OUTPUT_VERSION_AGE to 0, increment REVISION. For changing increment versionCurrent member of a parser but not setting versionAge to 0, increment REVISION. When changing REVISION, set PATCH to 0. From 94de29cbad81fee12fc18b21becec2dfe349c224 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Wed, 14 Dec 2022 00:53:07 +0900 Subject: [PATCH 6/7] main: introduce 'output version' Close #3583. Signed-off-by: Masatake YAMATO --- Tmain/extras-field-for-pseudo-tags.d/run.sh | 1 + Tmain/input-encoding-option.d/run.sh | 1 + Tmain/json-output-format.d/run.sh | 1 + Tmain/list-pseudo-tags.d/stdout-expected.txt | 1 + Tmain/output-encoding-option.d/run.sh | 1 + Tmain/ptag-kind-sep.d/run.sh | 1 + docs/man/ctags-client-tools.7.rst | 12 ++++++++++++ docs/man/ctags.1.rst | 4 ++-- main/ctags.h | 20 ++++++++++++++++++++ main/options.c | 2 ++ main/ptag.c | 13 +++++++++++++ main/ptag_p.h | 1 + man/ctags-client-tools.7.rst.in | 12 ++++++++++++ man/ctags.1.rst.in | 4 ++-- 14 files changed, 70 insertions(+), 4 deletions(-) diff --git a/Tmain/extras-field-for-pseudo-tags.d/run.sh b/Tmain/extras-field-for-pseudo-tags.d/run.sh index bceffd9300..698ce5e1a8 100644 --- a/Tmain/extras-field-for-pseudo-tags.d/run.sh +++ b/Tmain/extras-field-for-pseudo-tags.d/run.sh @@ -11,6 +11,7 @@ run_ctags() --pseudo-tags=-TAG_PROGRAM_VERSION \ --pseudo-tags=-TAG_PROC_CWD \ --pseudo-tags=-TAG_PARSER_VERSION \ + --pseudo-tags=-TAG_OUTPUT_VERSION \ $@ \ -o - input.c } diff --git a/Tmain/input-encoding-option.d/run.sh b/Tmain/input-encoding-option.d/run.sh index e9e8e76800..99167cbcc4 100644 --- a/Tmain/input-encoding-option.d/run.sh +++ b/Tmain/input-encoding-option.d/run.sh @@ -20,6 +20,7 @@ if ${CTAGS} --quiet --options=NONE --list-features | grep -q iconv; then --pseudo-tags=-TAG_FIELD_DESCRIPTION \ --pseudo-tags=-TAG_ROLE_DESCRIPTION \ --pseudo-tags=-TAG_PARSER_VERSION \ + --pseudo-tags=-TAG_OUTPUT_VERSION \ --input-encoding=utf-8 --input-encoding-java=shift_jis --input-encoding-javascript=euc-jp \ -o ${BUILDDIR}/tags \ input.js input.java ; then diff --git a/Tmain/json-output-format.d/run.sh b/Tmain/json-output-format.d/run.sh index 6e22322f2d..32cf72319a 100644 --- a/Tmain/json-output-format.d/run.sh +++ b/Tmain/json-output-format.d/run.sh @@ -12,6 +12,7 @@ if is_feature_available "${CTAGS}" json; then run_with_format json --languages=+man --fields="*"-T --extras='*' } | cat \ | grep -v TAG_PROGRAM_VERSION \ + | grep -v TAG_OUTPUT_VERSION \ | grep -v TAG_OUTPUT_FILESEP \ | grep -v TAG_PROC_CWD fi diff --git a/Tmain/list-pseudo-tags.d/stdout-expected.txt b/Tmain/list-pseudo-tags.d/stdout-expected.txt index 19c9ac6218..096383f22c 100644 --- a/Tmain/list-pseudo-tags.d/stdout-expected.txt +++ b/Tmain/list-pseudo-tags.d/stdout-expected.txt @@ -9,6 +9,7 @@ TAG_KIND_SEPARATOR off the separators used in kinds TAG_OUTPUT_EXCMD on the excmd: number, pattern, mixed, or combine TAG_OUTPUT_FILESEP on the separator used in file name (slash or backslash) TAG_OUTPUT_MODE on the output mode: u-ctags or e-ctags +TAG_OUTPUT_VERSION on the version of the output interface (current.age) TAG_PARSER_VERSION on the version of the parser (current.age) TAG_PATTERN_LENGTH_LIMIT on the limit of pattern length TAG_PROC_CWD on the current working directory of the tags generator diff --git a/Tmain/output-encoding-option.d/run.sh b/Tmain/output-encoding-option.d/run.sh index dcbf3b55c5..021e77df82 100644 --- a/Tmain/output-encoding-option.d/run.sh +++ b/Tmain/output-encoding-option.d/run.sh @@ -19,6 +19,7 @@ if ${CTAGS} --quiet --options=NONE --list-features | grep -q iconv; then --pseudo-tags=-TAG_EXTRA_DESCRIPTION \ --pseudo-tags=-TAG_ROLE_DESCRIPTION \ --pseudo-tags=-TAG_PARSER_VERSION \ + --pseudo-tags=-TAG_OUTPUT_VERSION \ --output-encoding=shift_jis --input-encoding=utf-8 --input-encoding-javascript=euc-jp \ -o ${BUILDDIR}/tags \ input.js input.java ; then diff --git a/Tmain/ptag-kind-sep.d/run.sh b/Tmain/ptag-kind-sep.d/run.sh index 30edf8166e..3b716af201 100644 --- a/Tmain/ptag-kind-sep.d/run.sh +++ b/Tmain/ptag-kind-sep.d/run.sh @@ -18,4 +18,5 @@ ${CTAGS} --quiet --options=NONE -o - \ --pseudo-tags=-TAG_EXTRA_DESCRIPTION \ --pseudo-tags=-TAG_ROLE_DESCRIPTION \ --pseudo-tags=-TAG_PARSER_VERSION \ + --pseudo-tags=-TAG_OUTPUT_VERSION \ input.php diff --git a/docs/man/ctags-client-tools.7.rst b/docs/man/ctags-client-tools.7.rst index f9cdf0cd7c..38ca150edd 100644 --- a/docs/man/ctags-client-tools.7.rst +++ b/docs/man/ctags-client-tools.7.rst @@ -220,6 +220,18 @@ for using notable ones. ``TAG_OUTPUT_MODE`` (new in Universal Ctags) TBW +``TAG_OUTPUT_VERSION`` (new in Universal Ctags 6.0) + Indicates the language-common interface version of the output:: + + !_TAG_OUTPUT_VERSION {current}.{age} /.../ + + The public interface includes common fields, common extras, + pseudo tags. + + The maintainer of Universal Ctags may update the numbers, + "{current}" and "{age}" in the same manner as explained + in ``TAG_PARSER_VERSION``. + ``TAG_PARSER_VERSION`` (new in Universal Ctags 6.0) Indicates the interface version of the parser:: diff --git a/docs/man/ctags.1.rst b/docs/man/ctags.1.rst index cbc349438b..ba4e95772a 100644 --- a/docs/man/ctags.1.rst +++ b/docs/man/ctags.1.rst @@ -1330,8 +1330,8 @@ Miscellaneous Options ``--version[=]`` Prints a version identifier for ctags to standard output, and then exits. This is guaranteed to always contain the string - "Universal Ctags". See also the description for ``TAG_PROGRAM_VERSION`` in - :ref:`ctags-client-tools(7) `. + "Universal Ctags". See also the description for ``TAG_PROGRAM_VERSION`` + and ``TAG_OUTPUT_VERSION`` in :ref:`ctags-client-tools(7) `. If ** is given, print the version identifier for the parser for **. See also the description for ``TAG_PARSER_VERSION`` in diff --git a/main/ctags.h b/main/ctags.h index cfaa3d9fa6..74644c8fa4 100644 --- a/main/ctags.h +++ b/main/ctags.h @@ -48,6 +48,26 @@ #define PROGRAM_COPYRIGHT "Copyright (C) 2015-2022" #define AUTHOR_NAME "Universal Ctags Team" +/* The concept of CURRENT and AGE is taken from libtool. + * However, we deleted REVISION in libtool when importing + * the concept of versioning from libtool. + * + * If common fields, common extras, pseudo tags have been added, + * removed or changed since last release, increment CURRENT. + * If they have been added since last release, increment AGE. + * If they have been removed since last release, set AGE to 0 + * + * From the command line of ctags, you can see the version + * information with --version and --version=NONE. + * + * In the tags file, !_TAGS_OUTPUT_VERSION shows the the version. + * + * Chaning for the command line interface, and implementation changes + * like bug fixes don't affect the CURRENT an AGE. + */ +#define OUTPUT_VERSION_CURRENT 0 +#define OUTPUT_VERSION_AGE 0 + /* * Constant */ diff --git a/main/options.c b/main/options.c index 15213be727..06f45bffcd 100644 --- a/main/options.c +++ b/main/options.c @@ -1614,6 +1614,8 @@ static void printProgramIdentification (void) printf (" Compiled: %s, %s\n", __DATE__, __TIME__); printf (" URL: %s\n", PROGRAM_URL); + printf (" Output version: %d.%d\n", + OUTPUT_VERSION_CURRENT, OUTPUT_VERSION_AGE); printFeatureList (); } diff --git a/main/ptag.c b/main/ptag.c index c8ca8d3588..f91fd83f26 100644 --- a/main/ptag.c +++ b/main/ptag.c @@ -139,6 +139,15 @@ static bool ptagMakeParserVersion(ptagDesc *desc, langType language, return writePseudoTag (desc, buf, "current.age", name); } +static bool ptagMakeOutputVersion (ptagDesc *desc, langType language, + const void *data CTAGS_ATTR_UNUSED) +{ + char buf[32]; /* 2^32 '.' 2^32 '\0' */ + snprintf (buf, sizeof(buf), "%u.%u", + OUTPUT_VERSION_CURRENT, OUTPUT_VERSION_AGE); + return writePseudoTag (desc, buf, "current.age", NULL); +} + static ptagDesc ptagDescs [] = { { /* The prefix is not "TAG_". @@ -222,6 +231,10 @@ static ptagDesc ptagDescs [] = { "the version of the parser (current.age)", ptagMakeParserVersion, PTAGF_PARSER }, + { true, "TAG_OUTPUT_VERSION", + "the version of the output interface (current.age)", + ptagMakeOutputVersion, + PTAGF_COMMON }, }; extern bool makePtagIfEnabled (ptagType type, langType language, const void *data) diff --git a/main/ptag_p.h b/main/ptag_p.h index 75355a16ae..f71431fc6e 100644 --- a/main/ptag_p.h +++ b/main/ptag_p.h @@ -44,6 +44,7 @@ typedef enum ePtagType { /* pseudo tag content control */ PTAG_PROC_CWD, PTAG_OUTPUT_EXCMD, PTAG_PARSER_VERSION, + PTAG_OUTPUT_VERSION, PTAG_COUNT } ptagType; diff --git a/man/ctags-client-tools.7.rst.in b/man/ctags-client-tools.7.rst.in index ccdd392e72..d11f3ee41d 100644 --- a/man/ctags-client-tools.7.rst.in +++ b/man/ctags-client-tools.7.rst.in @@ -220,6 +220,18 @@ for using notable ones. ``TAG_OUTPUT_MODE`` (new in Universal Ctags) TBW +``TAG_OUTPUT_VERSION`` (new in Universal Ctags 6.0) + Indicates the language-common interface version of the output:: + + !_TAG_OUTPUT_VERSION {current}.{age} /.../ + + The public interface includes common fields, common extras, + pseudo tags. + + The maintainer of Universal Ctags may update the numbers, + "{current}" and "{age}" in the same manner as explained + in ``TAG_PARSER_VERSION``. + ``TAG_PARSER_VERSION`` (new in Universal Ctags 6.0) Indicates the interface version of the parser:: diff --git a/man/ctags.1.rst.in b/man/ctags.1.rst.in index 3f73912f08..8e72cca9e9 100644 --- a/man/ctags.1.rst.in +++ b/man/ctags.1.rst.in @@ -1330,8 +1330,8 @@ Miscellaneous Options ``--version[=]`` Prints a version identifier for @CTAGS_NAME_EXECUTABLE@ to standard output, and then exits. This is guaranteed to always contain the string - "Universal Ctags". See also the description for ``TAG_PROGRAM_VERSION`` in - ctags-client-tools(7). + "Universal Ctags". See also the description for ``TAG_PROGRAM_VERSION`` + and ``TAG_OUTPUT_VERSION`` in ctags-client-tools(7). If ** is given, print the version identifier for the parser for **. See also the description for ``TAG_PARSER_VERSION`` in From 0a2c667fda815cf3a43395bf91016cef93107bbe Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Wed, 14 Dec 2022 03:11:23 +0900 Subject: [PATCH 7/7] main: add --version=NONE option for printing the version number in simplified style Close #2361. Signed-off-by: Masatake YAMATO --- docs/man/ctags.1.rst | 4 +++- main/options.c | 8 ++++++++ man/ctags.1.rst.in | 4 +++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/man/ctags.1.rst b/docs/man/ctags.1.rst index ba4e95772a..6bca79d3f3 100644 --- a/docs/man/ctags.1.rst +++ b/docs/man/ctags.1.rst @@ -1327,12 +1327,14 @@ Miscellaneous Options ``-V`` Equivalent to ``--verbose``. -``--version[=]`` +``--version[=|NONE]`` Prints a version identifier for ctags to standard output, and then exits. This is guaranteed to always contain the string "Universal Ctags". See also the description for ``TAG_PROGRAM_VERSION`` and ``TAG_OUTPUT_VERSION`` in :ref:`ctags-client-tools(7) `. + If ``NONE`` is given, prints the version identifier in a simplified way. + If ** is given, print the version identifier for the parser for **. See also the description for ``TAG_PARSER_VERSION`` in :ref:`ctags-client-tools(7) `. diff --git a/main/options.c b/main/options.c index 06f45bffcd..b00a707773 100644 --- a/main/options.c +++ b/main/options.c @@ -2687,6 +2687,14 @@ static void processVersionOption ( { if (parameter == NULL || *parameter == '\0') printProgramIdentification (); + else if (strcmp (parameter, RSV_NONE) == 0) + { + printf("ctags: %s\n", PROGRAM_VERSION); + if (! ((ctags_repoinfo == NULL) + || (strcmp (ctags_repoinfo, PROGRAM_VERSION) == 0))) + printf("repoinfo: %s\n", ctags_repoinfo); + printf("output: %d.%d\n", OUTPUT_VERSION_CURRENT, OUTPUT_VERSION_AGE); + } else { langType language = getNamedLanguage (parameter, 0); diff --git a/man/ctags.1.rst.in b/man/ctags.1.rst.in index 8e72cca9e9..36d2839deb 100644 --- a/man/ctags.1.rst.in +++ b/man/ctags.1.rst.in @@ -1327,12 +1327,14 @@ Miscellaneous Options ``-V`` Equivalent to ``--verbose``. -``--version[=]`` +``--version[=|NONE]`` Prints a version identifier for @CTAGS_NAME_EXECUTABLE@ to standard output, and then exits. This is guaranteed to always contain the string "Universal Ctags". See also the description for ``TAG_PROGRAM_VERSION`` and ``TAG_OUTPUT_VERSION`` in ctags-client-tools(7). + If ``NONE`` is given, prints the version identifier in a simplified way. + If ** is given, print the version identifier for the parser for **. See also the description for ``TAG_PARSER_VERSION`` in ctags-client-tools(7).