Skip to content

Commit 126781c

Browse files
authored
Merge pull request #1737 from masatake/strict-naming-rules
[INCOMPATIBLE][SELF INCOMPATIBLE] main,Tmain: revise acceptable characters for kind letters and kind names
2 parents 6adbc59 + e6d75a1 commit 126781c

File tree

19 files changed

+393
-41
lines changed

19 files changed

+393
-41
lines changed

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Universal Ctags
32

43
[![Build Status](https://travis-ci.org/universal-ctags/ctags.svg?branch=master)](https://travis-ci.org/universal-ctags/ctags)
@@ -57,18 +56,37 @@ In addition rst2man command is needed.
5756

5857
rst2man is part of the python-docutils package on Ubuntu.
5958

60-
## Difference ##
59+
## Differences ##
6160

6261
You may be interested in how universal-ctags is different from
6362
exuberant-ctags. The critical and attractive changes are explained
6463
in docs/\*.rst. The preformatted version is available on line,
6564
http://docs.ctags.io/.
6665

67-
The most significant one is that Universal-ctags doesn't load
66+
The most significant incompatible changes:
67+
68+
* Universal-ctags doesn't load
6869
`~/.ctags` and `./.ctags` at starting up time. Instead, it loads
6970
`~/.ctags.d/*.ctags` and `./.ctags.d/*.ctags`. See the above web
7071
site and man pages
7172
(man/ctags.1.rst.in and man/ctags-incompatibilities.7.in in the
7273
source tree).
7374

75+
* Universal-ctags is more strict about characters that can be
76+
used in kind letters and kind names than Exuberant-ctags.
77+
78+
- The letter must be an alphabetical character (`[a-zA-EG-Z]`).
79+
`F` is reserved for `file` kind.
80+
81+
- The first character of the name must be alphabetic, and
82+
the rest characters must be alphanumeric (`[a-zA-Z][a-zA-Z0-9]*`).
83+
84+
See the web site and man pages. The detailed background is explained
85+
in [#1737](https://github.com/universal-ctags/ctags/pull/1737).
86+
87+
If you want to reuse your .ctags written for Exuberant-ctags,
88+
you must review kind letters and names defined with `--regex-<LANG>=...`
89+
options. When updating the definitions, using `--kind-<LANG>` option
90+
is appreciated.
91+
7492
Pull-requests are welcome!

Tmain/kinddef.d/run.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ ${CTAGS} --kinddef-MYTEST= --list-kinds-full=MYTEST
6868
title '# wrong letter'
6969
${CTAGS} --kinddef-MYTEST=^ --list-kinds-full=MYTEST
7070

71+
title '# wrong letter (using number)'
72+
${CTAGS} --kinddef-MYTEST=7 --list-kinds-full=MYTEST
73+
7174
title '# reusing the letter for file kind'
7275
${CTAGS} --kinddef-MYTEST=F --list-kinds-full=MYTEST
7376

@@ -89,6 +92,12 @@ ${CTAGS} --kinddef-MYTEST='x,kind,desc\{' --list-kinds-full=MYTEST
8992
title '# use a { in description (2)'
9093
${CTAGS} --kinddef-MYTEST='x,kind,desc\{}' --list-kinds-full=MYTEST
9194

95+
title '# use a number char as the initial letter'
96+
${CTAGS} --kinddef-MYTEST='x,0kind,desc' --list-kinds-full=MYTEST
97+
98+
title '# use a number char within the body'
99+
${CTAGS} --kinddef-MYTEST='x,k0ind,desc' --list-kinds-full=MYTEST
100+
92101
# title '# use a { and \t in description'
93102
# ${CTAGS} --kinddef-MYTEST='x,kind,desc\{}\t' --list-kinds-full=MYTEST
94103

Tmain/kinddef.d/stderr-expected.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ ctags: the kind name in "--kinddef-MYTEST" option is empty
2323
ctags: the kind name in "--kinddef-MYTEST" option is empty
2424

2525
# wrong letter in name 1
26-
ctags: unacceptable char as part of kind name in "--kinddef-MYTEST" option
26+
ctags: non-alphanumeric char is used as part of kind name: 'a x' in "--kinddef-MYTEST" option
2727

2828
# wrong letter in name 2
29-
ctags: unacceptable char as part of kind name in "--kinddef-MYTEST" option
29+
ctags: non-alphanumeric char is used as part of kind name: 'a x' in "--kinddef-MYTEST" option
3030

3131
# wrong letter in name 3
3232
ctags: no kind description specified in "--kinddef-MYTEST" option
@@ -47,7 +47,10 @@ ctags: no kind letter specified in "--kinddef-MYTEST" option
4747
ctags: no kind definition specified in "--kinddef-MYTEST" option
4848

4949
# wrong letter
50-
ctags: the kind letter given in "--kinddef-MYTEST" option is not an alphabet or a number
50+
ctags: the kind letter given in "--kinddef-MYTEST" option is not an alphabet
51+
52+
# wrong letter (using number)
53+
ctags: the kind letter given in "--kinddef-MYTEST" option is not an alphabet
5154

5255
# reusing the letter for file kind
5356
ctags: the kind letter `F' in "--kinddef-MYTEST" option is reserved for "file" kind
@@ -67,6 +70,11 @@ ctags: Warning: long flags specifier opened with `{' is not closed `}': "{"
6770

6871
# use a { in description (2)
6972

73+
# use a number char as the initial letter
74+
ctags: a kind name doesn't start with an alphabetical character: '0kind' in "--kinddef-MYTEST" option
75+
76+
# use a number char within the body
77+
7078
# use a \ in description
7179

7280
# description started from {

Tmain/kinddef.d/stdout-expected.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ a aa yes no 0 NONE aaa
3535

3636
# wrong letter
3737

38+
# wrong letter (using number)
39+
3840
# reusing the letter for file kind
3941

4042
# reusing the name for file kind
@@ -59,6 +61,12 @@ x kind yes no 0 NONE desc{
5961
#LETTER NAME ENABLED REFONLY NROLES MASTER DESCRIPTION
6062
x kind yes no 0 NONE desc{}
6163

64+
# use a number char as the initial letter
65+
66+
# use a number char within the body
67+
#LETTER NAME ENABLED REFONLY NROLES MASTER DESCRIPTION
68+
x k0ind yes no 0 NONE desc
69+
6270
# use a \ in description
6371
#LETTER NAME ENABLED REFONLY NROLES MASTER DESCRIPTION
6472
x kind yes no 0 NONE desc\backslash

Tmain/lregex-kind-letter.d/run.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright: 2018 Masatake YAMATO
2+
# License: GPL-2
3+
4+
CTAGS="$1 --quiet --options=NONE"
5+
6+
. ../utils.sh
7+
8+
echo2 param: '|(.)|\1|^ => ignoring'
9+
${CTAGS} --langdef=x --regex-x='|(.)|\1|^' --list-kinds-full=x
10+
# In this case, ctags ignores the substring after the last '|'.
11+
# It is evaluated as flags.
12+
13+
echo2 param: '|(.)|\1|^| => warning'
14+
${CTAGS} --langdef=x --regex-x='|(.)|\1|^|' --list-kinds-full=x
15+
# In this case, ctags warns specifying a wrong kind letter '^'.
16+
17+
echo2 param: '|(.)|\1|, => ignoring'
18+
${CTAGS} --langdef=x --regex-x='|(.)|\1|,' --list-kinds-full=x
19+
# In this case, ctags ignores the substring after the last '|'.
20+
# It is evaluated as flags.
21+
22+
echo2 param: '|(.)|\1|,| => using the default letter and name'
23+
${CTAGS} --langdef=x --regex-x='|(.)|\1|,|' --list-kinds-full=x
24+
# In this case, ctags recognizes a kind letter and name
25+
# are not given; 'r' and "regex" are used as default values.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
param: |(.)|\1|^ => ignoring
2+
param: |(.)|\1|^| => warning
3+
ctags: Kind letter must be an alphabetical character: "^"
4+
param: |(.)|\1|, => ignoring
5+
param: |(.)|\1|,| => using the default letter and name
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
param: |(.)|\1|^ => ignoring
2+
#LETTER NAME ENABLED REFONLY NROLES MASTER DESCRIPTION
3+
r regex yes no 0 NONE regex
4+
param: |(.)|\1|^| => warning
5+
param: |(.)|\1|, => ignoring
6+
#LETTER NAME ENABLED REFONLY NROLES MASTER DESCRIPTION
7+
r regex yes no 0 NONE regex
8+
param: |(.)|\1|,| => using the default letter and name
9+
#LETTER NAME ENABLED REFONLY NROLES MASTER DESCRIPTION
10+
r regex yes no 0 NONE regex

Tmain/lregex-kind-name.d/run.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright: 2018 Masatake YAMATO
2+
# License: GPL-2
3+
4+
CTAGS="$1 --quiet --options=NONE"
5+
6+
. ../utils.sh
7+
8+
echo2 param: '|(.)|\1|x,name| => acceptable'
9+
${CTAGS} --langdef=x --regex-x='|(.)|\1|x,name|' --list-kinds-full=x
10+
11+
echo2 param: '|(.)|\1|x,name,documents| => acceptable'
12+
${CTAGS} --langdef=x --regex-x='|(.)|\1|x,name,documents|' --list-kinds-full=x
13+
14+
echo2 param: '|(.)|\1|x,name,0documents| => acceptable'
15+
${CTAGS} --langdef=x --regex-x='|(.)|\1|x,name,0documents|' --list-kinds-full=x
16+
17+
echo2 param: '|(.)|\1|x,name,doc uments| => acceptable'
18+
${CTAGS} --langdef=x --regex-x='|(.)|\1|x,name,doc uments|' --list-kinds-full=x
19+
20+
echo2 param: '|(.)|\1|x,name0| => acceptable'
21+
${CTAGS} --langdef=x --regex-x='|(.)|\1|x,name0|' --list-kinds-full=x
22+
23+
echo2 param: '|(.)|\1|x,name0,documents| => acceptable'
24+
${CTAGS} --langdef=x --regex-x='|(.)|\1|x,name0,documents|' --list-kinds-full=x
25+
26+
echo2 param: '|(.)|\1|x,name0,0documents| => acceptable'
27+
${CTAGS} --langdef=x --regex-x='|(.)|\1|x,name0,0documents|' --list-kinds-full=x
28+
29+
echo2 param: '|(.)|\1|x,name0,doc uments| => acceptable'
30+
${CTAGS} --langdef=x --regex-x='|(.)|\1|x,name0,doc uments|' --list-kinds-full=x
31+
32+
echo2 param: '|(.)|\1|x,0name| => unacceptable'
33+
${CTAGS} --langdef=x --regex-x='|(.)|\1|x,0name|' --list-kinds-full=x
34+
35+
echo2 param: '|(.)|\1|x,0name,documents| => unacceptable'
36+
${CTAGS} --langdef=x --regex-x='|(.)|\1|x,0name,documents|' --list-kinds-full=x
37+
38+
echo2 param: '|(.)|\1|x,0name,0documents| => unacceptable'
39+
${CTAGS} --langdef=x --regex-x='|(.)|\1|x,0name,0documents|' --list-kinds-full=x
40+
41+
echo2 param: '|(.)|\1|x,0name,doc uments| => unacceptable'
42+
${CTAGS} --langdef=x --regex-x='|(.)|\1|x,0name,doc uments|' --list-kinds-full=x
43+
44+
echo2 param: '|(.)|\1|x,na me| => unacceptable'
45+
${CTAGS} --langdef=x --regex-x='|(.)|\1|x,na me|' --list-kinds-full=x
46+
47+
echo2 param: '|(.)|\1|x,na me,documents| => unacceptable'
48+
${CTAGS} --langdef=x --regex-x='|(.)|\1|x,na me,documents|' --list-kinds-full=x
49+
50+
echo2 param: '|(.)|\1|x,na me,0documents| => unacceptable'
51+
${CTAGS} --langdef=x --regex-x='|(.)|\1|x,na me,0documents|' --list-kinds-full=x
52+
53+
echo2 param: '|(.)|\1|x,na me,doc uments| => unacceptable'
54+
${CTAGS} --langdef=x --regex-x='|(.)|\1|x,na me,doc uments|' --list-kinds-full=x
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
param: |(.)|\1|x,name| => acceptable
2+
param: |(.)|\1|x,name,documents| => acceptable
3+
param: |(.)|\1|x,name,0documents| => acceptable
4+
param: |(.)|\1|x,name,doc uments| => acceptable
5+
param: |(.)|\1|x,name0| => acceptable
6+
param: |(.)|\1|x,name0,documents| => acceptable
7+
param: |(.)|\1|x,name0,0documents| => acceptable
8+
param: |(.)|\1|x,name0,doc uments| => acceptable
9+
param: |(.)|\1|x,0name| => unacceptable
10+
ctags: A kind name doesn't start with an alphabetical character: '0name' in "--regex-x" option
11+
param: |(.)|\1|x,0name,documents| => unacceptable
12+
ctags: A kind name doesn't start with an alphabetical character: '0name' in "--regex-x" option
13+
param: |(.)|\1|x,0name,0documents| => unacceptable
14+
ctags: A kind name doesn't start with an alphabetical character: '0name' in "--regex-x" option
15+
param: |(.)|\1|x,0name,doc uments| => unacceptable
16+
ctags: A kind name doesn't start with an alphabetical character: '0name' in "--regex-x" option
17+
param: |(.)|\1|x,na me| => unacceptable
18+
ctags: Non-alphanumeric char is used in kind name: 'na me' in "--regex-x" option
19+
param: |(.)|\1|x,na me,documents| => unacceptable
20+
ctags: Non-alphanumeric char is used in kind name: 'na me' in "--regex-x" option
21+
param: |(.)|\1|x,na me,0documents| => unacceptable
22+
ctags: Non-alphanumeric char is used in kind name: 'na me' in "--regex-x" option
23+
param: |(.)|\1|x,na me,doc uments| => unacceptable
24+
ctags: Non-alphanumeric char is used in kind name: 'na me' in "--regex-x" option
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
param: |(.)|\1|x,name| => acceptable
2+
#LETTER NAME ENABLED REFONLY NROLES MASTER DESCRIPTION
3+
x name yes no 0 NONE name
4+
param: |(.)|\1|x,name,documents| => acceptable
5+
#LETTER NAME ENABLED REFONLY NROLES MASTER DESCRIPTION
6+
x name yes no 0 NONE documents
7+
param: |(.)|\1|x,name,0documents| => acceptable
8+
#LETTER NAME ENABLED REFONLY NROLES MASTER DESCRIPTION
9+
x name yes no 0 NONE 0documents
10+
param: |(.)|\1|x,name,doc uments| => acceptable
11+
#LETTER NAME ENABLED REFONLY NROLES MASTER DESCRIPTION
12+
x name yes no 0 NONE doc uments
13+
param: |(.)|\1|x,name0| => acceptable
14+
#LETTER NAME ENABLED REFONLY NROLES MASTER DESCRIPTION
15+
x name0 yes no 0 NONE name0
16+
param: |(.)|\1|x,name0,documents| => acceptable
17+
#LETTER NAME ENABLED REFONLY NROLES MASTER DESCRIPTION
18+
x name0 yes no 0 NONE documents
19+
param: |(.)|\1|x,name0,0documents| => acceptable
20+
#LETTER NAME ENABLED REFONLY NROLES MASTER DESCRIPTION
21+
x name0 yes no 0 NONE 0documents
22+
param: |(.)|\1|x,name0,doc uments| => acceptable
23+
#LETTER NAME ENABLED REFONLY NROLES MASTER DESCRIPTION
24+
x name0 yes no 0 NONE doc uments
25+
param: |(.)|\1|x,0name| => unacceptable
26+
param: |(.)|\1|x,0name,documents| => unacceptable
27+
param: |(.)|\1|x,0name,0documents| => unacceptable
28+
param: |(.)|\1|x,0name,doc uments| => unacceptable
29+
param: |(.)|\1|x,na me| => unacceptable
30+
param: |(.)|\1|x,na me,documents| => unacceptable
31+
param: |(.)|\1|x,na me,0documents| => unacceptable
32+
param: |(.)|\1|x,na me,doc uments| => unacceptable

0 commit comments

Comments
 (0)