Skip to content

Conversation

masatake
Copy link
Member

@masatake masatake commented Jun 8, 2025

When releasing, I have to update the NEWS file.
One important topic is how parsers are enhanced, with new kinds, roles, fields, and extras (KRFX).
We have added and updated the 'ctags-lang-*' man pages mainly to track the KRFX.
Updating the man pages only to track them is a boring task.
Instead, making ctags itself report new KRFX.

This change adds version members to KRFX definitions.

Various-- list* commands show the version numbers in the VER column:

$ ./ctags --list-kinds-full=Automake
#LETTER NAME      ENABLED REFONLY NROLES MASTER VER DESCRIPTION
D       data      yes     no      0      NONE     0 datum
L       library   yes     no      0      NONE     0 libraries
M       man       yes     no      0      NONE     0 manuals
P       program   yes     no      0      NONE     0 programs
S       script    yes     no      0      NONE     0 scripts
T       ltlibrary yes     no      0      NONE     0 ltlibraries
c       condition yes     yes     1      NONE     0 conditions
d       directory yes     no      6      NONE     0 directories
p       pseudodir no      yes     6      NONE     1 placeholder for EXTRA_, noinst_, ...
s       subdir    yes     no      0      NONE     0 subdirs

--describe-language option was added.

$ ./ctags --describe-language=RpmMacros          
About RpmMacros language
=======================================================
enabled: yes
version: 0.0

Mappings/patterns
-------------------------------------------------------


Mappings/extensions
-------------------------------------------------------


Aliases
-------------------------------------------------------
#ALIAS

Kinds
-------------------------------------------------------
#LETTER NAME  ENABLED REFONLY NROLES MASTER VER DESCRIPTION
m       macro yes     no      0      NONE     0 macros

Roles
-------------------------------------------------------
#KIND(L/N) NAME ENABLED VER DESCRIPTION

Fields
-------------------------------------------------------
#LETTER NAME ENABLED LANGUAGE JSTYPE FIXED OP VER DESCRIPTION

Extras
-------------------------------------------------------
#LETTER NAME ENABLED LANGUAGE FIXED VER DESCRIPTION

Parameters
-------------------------------------------------------
#NAME DESCRIPTION

Sub parsers stacked on this parser
-------------------------------------------------------
#NAME BASEPARSER DIRECTIONS

Implementation specific status
-------------------------------------------------------
allow null tags: no

TODO:

  • implement --list-languages-full
  • update ctags.1.rst
  • add test cases
  • describe versioning in hacking guide
  • ...

Copy link

codecov bot commented Sep 26, 2025

Codecov Report

❌ Patch coverage is 85.83333% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.89%. Comparing base (e6a4947) to head (afede55).

Files with missing lines Patch % Lines
main/parse.c 76.92% 6 Missing ⚠️
main/kind.c 54.54% 5 Missing ⚠️
main/options.c 94.20% 4 Missing ⚠️
main/field.c 66.66% 1 Missing ⚠️
main/xtag.c 66.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master    #4271    +/-   ##
========================================
  Coverage   85.88%   85.89%            
========================================
  Files         248      248            
  Lines       63602    63717   +115     
========================================
+ Hits        54624    54727   +103     
- Misses       8978     8990    +12     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

In d469bf9, I forgot to update
versionCurrent and versionAge member of the parser.

(This means the parser versioning of ctags-6.2 is broken.
I must backport this change to ctags-6.2 and release 6.2.1.)

Signed-off-by: Masatake YAMATO <[email protected]>
* add VER column to --list-kinds-full output, and
* add {version=} flag to --kinddef-<LANG> option.

Signed-off-by: Masatake YAMATO <[email protected]>
* add VER column to --list-roles output, and
* add {version=} flag to --_roledef-<LANG> option.

Signed-off-by: Masatake YAMATO <[email protected]>
* add VER column to --list-fields output, and
* add {version=} flag to --_fielddef-<LANG> option.

Signed-off-by: Masatake YAMATO <[email protected]>
@masatake masatake force-pushed the main--show-version-in-list branch from 58c55a8 to afede55 Compare October 13, 2025 09:09
@masatake masatake changed the title [WIP] enhance parser versioning main: enhance parser versioning Oct 13, 2025
@masatake masatake marked this pull request as ready for review October 13, 2025 09:11
* add VER column to --list-extras output, and
* add {version=} flag to --_extradef-<LANG> option.

Signed-off-by: Masatake YAMATO <[email protected]>
Add VER column to --list-pseudo-tags output.

Signed-off-by: Masatake YAMATO <[email protected]>
@masatake masatake force-pushed the main--show-version-in-list branch from afede55 to f6101db Compare October 13, 2025 09:25
@masatake
Copy link
Member Author

An interesting bug(?):

--- ./Tmain/versioning.d/stderr-expected.txt	2025-10-13 09:27:51.780878500 +0000
	+++ D:/a/ctags/ctags/Tmain/versioning.d/stderr-actual.txt	2025-10-13 09:31:00.757293100 +0000
	@@ -1,8 +1,8 @@
	-ctags: Faile to parse the version number for kind "def": -1
	-kind: 1
	-ctags: Faile to parse the version number for role "expanded": -2
	-role: 1
	-ctags: Faile to parse the version number for field "param": -3
	-field: 1
	-ctags: Faile to parse the version number for extra "fullname": -4
	-extra: 1
	+ctags: Warning: the version number (4294967295) of kind "d,def" of language "TEST" should be less than or equal to the current number (10) of the language
	+kind: 0
	+ctags: Warning: the version number (4294967294) of role "expanded" of language "TEST" should be less than or equal to the current number (10) of the language
	+role: 0
	+ctags: Warning: the version number (4294967293) of extra "param" of language "TEST" should be less than or equal to the current number (10) of the language
	+field: 0
	+ctags: Warning: the version number (4294967292) of extra "fullname" of language "TEST" should be less than or equal to the current number (10) of the language
	+extra: 0

It seems that strtoul accepts "-1" on the platform.

@masatake
Copy link
Member Author

masatake commented Oct 13, 2025

strToULong("-1", 10, ...) returns true.

The behavior is valid as strtoul(1) page explains:


RETURN VALUE
       The  strtoul()  function returns either the result of the conversion or,
       if there was a leading minus sign, the negation of  the  result  of  the
       conversion  represented  as an unsigned value, unless the original (non‐
       negated) value would overflow; in the  latter  case,  strtoul()  returns
       ULONG_MAX  and  sets errno to ERANGE.  Precisely the same holds for str‐
       toull() (with ULLONG_MAX instead of ULONG_MAX).

I have expected the strtou functions rejected negative numbers.
I must verify the code using the functions.

make tutil with the following change demonstrating my misunderstanding:

diff --git a/extra-cmds/utiltest.c b/extra-cmds/utiltest.c
index 76d919139..5bd968a3a 100644
--- a/extra-cmds/utiltest.c
+++ b/extra-cmds/utiltest.c
@@ -277,6 +277,15 @@ static void test_routines_strrstr(void)
    TEST_CHECK(strcmp(strrstr("abcdcdb", "cd"), "cdb") == 0);
 }
 
+static void test_routines_strToU(void)
+{
+   unsigned long ul_tmp;
+   unsigned int ui_tmp;
+
+   TEST_CHECK(strToULong("-1", 10, &ul_tmp) == false);
+   TEST_CHECK(strToUInt("-2", 10, &ui_tmp) == false);
+}
+
 static void test_vstring_ncats(void)
 {
    vString *vstr = vStringNew ();
@@ -351,6 +360,7 @@ TEST_LIST = {
    { "intern",           test_intern           },
    { "numarray",         test_numarray         },
    { "routines/strrstr", test_routines_strrstr },
+   { "routines/strToU", test_routines_strToU },
    { "vstring/ncats",    test_vstring_ncats    },
    { "vstring/truncate_leading", test_vstring_truncate_leading },
    { "vstring/EqC",      test_vstring_eqc },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant