Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't pre-process the macro but it works with Exuberant Ctags 5.8 #2356

Open
mtozjh opened this issue Dec 2, 2019 · 7 comments
Open

can't pre-process the macro but it works with Exuberant Ctags 5.8 #2356

mtozjh opened this issue Dec 2, 2019 · 7 comments
Labels
Documentation FAQ This should be part of FAQ. multipass issues which can be fixed with multi-pass parsing feature
Milestone

Comments

@mtozjh
Copy link

mtozjh commented Dec 2, 2019

(
Thank you for contacting us.

If you are reporting an issue with the parsing output, please fill
the following template. As your custom CTags configuration can
affect results, please always use --options=NONE as the first
option when running ctags.

Otherwise, delete the template and write your issue from scratch.
Examples may help developers understanding your issue better.

Use GitHub web interface and markdown notation.
Using mail results broken text rendering that makes
the developers go crazy.
)


The name of the parser:
c/c++

The command line you used to run ctags:

$ ctags --languages=C,C++,FORTRAN --recurse=no -n --fields=+iaSklnezs

The content of input file:

/* THIS IS AN EXAMPLE */

void FTNC(etmif_set_argv)(double *value, int *i)
{
  ETMIF_argv[*i] = *value;

  return;
}


The tags output you are not satisfied with:

FTNC /u/yanchen/.FAST_9995.src.c 6562;" kind:f line:6562 language:C typeref:typename:void signature:(etmif_set_argv) end:6666

The tags output you expect:

etmif_set_argv	/u/yanchen/.FAST_9995.src.c	6562;"	kind:f	line:6562	language:C	typeref:typename:void	signature:(double *value, int *i)	end:6666
...

The version of ctags:

$ ctags --version

Universal Ctags 0.0.0, Copyright (C) 2015 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Dec  2 2019, 05:44:39
  URL: https://ctags.io/
  Optional compiled features: +wildcards, +regex, +iconv, +option-directory, +packcc


How do you get ctags binary:

(
Building it locally, via GITHUB latest version
)
@masatake
Copy link
Member

masatake commented Dec 2, 2019

C parser is completely rewritten in u-ctags. Please, use -D option as shown below.

$ cat /tmp/foo.c
void FTNC(etmif_set_argv)(double *value, int *i)
{
  ETMIF_argv[*i] = *value;

  return;
}
$ ./ctags -o - -D'FTNC(n)=n' /tmp/foo.c
etmif_set_argv	/tmp/foo.c	/^void FTNC(etmif_set_argv)(double *value, int *i)$/;"	f	language:C	typeref:typename:void

@masatake masatake added FAQ This should be part of FAQ. Documentation labels Dec 2, 2019
@masatake masatake added this to the M1 for 6.0 milestone Dec 2, 2019
@mtozjh
Copy link
Author

mtozjh commented Dec 3, 2019

Thanks for the quick response.
I know this workaround. Actually I am looking for the behavior like Exuberant Ctas 5.8. Since there are thousands of C/CPP files, it is heavy burden for user to work around all MACRO like this.

will you deliver an enhancement?

@masatake
Copy link
Member

masatake commented Dec 3, 2019

will you deliver an enhancement?

Yes, but I will take more than 1 year to implement it.

ctags itself knows the definitions of macro.

$ cat /tmp/foo.h
#define FTNC(f) f
$./ctags -o - --fields-C++=+'{macrodef}' /tmp/foo.h
FTNC	/tmp/foo.h	/^#define FTNC(/;"	d	language:C++	macrodef:f

So ctags can prepare the arugments for -D option by itself.

I had a prototype and it worked.

However, what I have to do is written in #1038 .

@mtozjh
Copy link
Author

mtozjh commented Dec 3, 2019

Look forward to that release.

BTY, this is really a great tool.

@masatake
Copy link
Member

masatake commented Dec 3, 2019

We added so many features, so I cannot remember them timely.

If it is acceptable to run ctags twice, you don't have to specify -D option manually.

$ cat /tmp/foo.h
#define FTNC(f) f
#define BODY(x) { return (x); }
#define R(B) int B
R(FTNC(func)(FTCN(int i))BODY(x))
$ ./ctags -o /tmp/foo.ctags --fields-C++=+'{macrodef}' --fields=+S -x --_xformat="-D%{name}%{signature}=%{C++.macrodef}" /tmp/foo.h
$ ./ctags -o - --options=/tmp/foo.ctags  /tmp/foo.h
BODY	/tmp/foo.h	/^#define BODY(/;"	d	language:C++
FTNC	/tmp/foo.h	/^#define FTNC(/;"	d	language:C++
R	/tmp/foo.h	/^#define R(/;"	d	language:C++
func	/tmp/foo.h	/^R(FTNC(func)(FTCN(int i))BODY(x))$/;"	f	language:C++	typeref:typename:int

@pragmaware, you may be interested in this output.
I'm surprised at this works well.

@masatake
Copy link
Member

masatake commented Dec 3, 2019

./ctags -o - --languages=+OldC --language-force=OldC ...

runs old C parser inherited from Exuberant Ctags. (But we will not fix the bug for it even if we got a bug report.)

@masatake
Copy link
Member

See #2427.
If a macro is defined in the same input file and ifdefs are not used aggressively, macros can be expanded automatically.

@masatake masatake added the multipass issues which can be fixed with multi-pass parsing feature label Apr 8, 2020
hirooih added a commit to hirooih/ctags that referenced this issue Feb 8, 2021
- new sections:
  - Does Universal Ctags support Unicode file names?
  - Why does zsh cause "zsh: no matches found" error?
- add TODO comment for universal-ctags#1421, universal-ctags#2356, and universal-ctags#2540
hirooih added a commit to hirooih/ctags that referenced this issue Feb 9, 2021
- new sections:
  - Does Universal Ctags support Unicode file names?
  - Why does zsh cause "zsh: no matches found" error?
- add TODO comment for universal-ctags#1421, universal-ctags#2356, and universal-ctags#2540
@masatake masatake modified the milestones: M1 for 6.0, M0 for 6.0 Dec 2, 2022
@masatake masatake modified the milestones: 6.0, 6.1 Dec 2, 2022
@masatake masatake modified the milestones: 6.1, 6.2 Dec 15, 2022
@masatake masatake modified the milestones: 6.2, 6.3 Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation FAQ This should be part of FAQ. multipass issues which can be fixed with multi-pass parsing feature
Projects
None yet
Development

No branches or pull requests

2 participants