universal-ctags / ctags

A maintained ctags implementation
https://ctags.io
GNU General Public License v2.0
6.56k stars 626 forks source link

whitespaces in tags file (--dont-use-whitespaces-in-name should be added) #499

Closed masatake closed 1 year ago

masatake commented 9 years ago

I recognized this issue during writing for a test case for rpsec input( #453 )

Loot at our bible, docs/format.rst:

   {tagname}
    Any identifier, not containing white space..

Some parsers violate this rule. About lua, I fixed in #491. This is just a bug of parser. Not so interesting. There is case that a target language, not a parser allows whitespaces in an object which a parser for the target language will record as a tag.

In all of the cases the target languages are for documentation tools. Here is an example.

[yamato@x201]~/var/ctags-github% cat /tmp/foo.rst 
Joy of hacking universal ctags
========================================
[yamato@x201]~/var/ctags-github% ./ctags -o - /tmp/foo.rst 
Joy of hacking universal ctags  /tmp/foo.rst    /^Joy of hacking universal ctags$/;"    c

tex is another example:

[yamato@x201]~/var/ctags-github% cat /tmp/foo.tex        
\section{The joy of hacking ctags}

[yamato@x201]~/var/ctags-github% ctags -o -  /tmp/foo.tex
ctags: Warning: Ignoring non-option in ./.ctags

The joy of hacking ctags    /tmp/foo.tex    /^\\section{The joy of hacking ctags}$/;"   s

This one is reproducible in exuberant ctags.

What we should do?

I think the most of tools reading tags just look at tab. So spaces are accetable. Actually we don't receive any bug report about it. However, we have to write "universal ctags violates this rule. universal ctags allows spaces in tagname." Alternative approach is replacing a space with _.

The real issue is a tab. If a tag name includes a tab, what we should do? My idea is just throwing away the tag in a parser level, not in entry.c till we receive a bug report.

Any comment?

ffes commented 9 years ago

Just a short note, we are about to leave for Prague 😉

CSS can give tags with spaces as well. When the CSS parser was updates by @b4n a while ago (don't have time to git blame right now, sorry) we discussed that as well. Don't remember the exact outcome of that discussion.

masatake commented 9 years ago

@ffes, thank you. I will search the outcome.

masatake commented 9 years ago

I found it in #119. The outcome is that we just accept spaces. So I will update docs/format.rst. I also add an assertion that tags should not contain tabs. I will make a PR for this.

masatake commented 9 years ago

zsh completion rules for less command expect a tagname doesn't contain a space. -t option of less command also expects it.

I would like to think about this issue more.

masatake commented 9 years ago

I'm thinking about introducing options to specify how spaces in a name is handled when ctags prints such name.

cweagans commented 9 years ago

Sorry for the noise. Just switching the "Release blocker" tag for the "Initial release" milestone so that everything is tracked in one place.

masatake commented 8 years ago

If an option like --dont-use-whitespace-in-name, we can replace it with _ or -. In this case ctags should record the option is specified in a pseudo tag.

But I would like to introduce such option in 1.1.0, not in 1.0.0. Because, I would like to overhaul the whole area releated to pseudo tag in 1.1.0.

So what we should do in 1.0.0. is writing that we allow ctags using whitespaces in name to FORMAT file. I will write a draft version. I would like other to review it.

masatake commented 8 years ago

Suprisingly I already wrote in docs/format.rst. So let's move this to 1.1.0.

masatake commented 1 year ago

--output-format=u-ctags|e-ctags option and !_TAG_OUTPUT_FORMAT pseudo tag solved this isseu. u-ctags specific behavior is explained in tags(5).