universal-ctags / ctags

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

Partial support for g:gutentags_ctags_extra_args #1760

Closed CatalinGB closed 6 years ago

CatalinGB commented 6 years ago

Hello,

Autosar uses for C development certain compiler abstraction macros like:

#define FUNC(rettype, memclass)

One way to generate a correct tags file is to call ctags with -D "FUNC(rettype, memclass) memclass rettype"

When I try to use let g:gutentags_ctags_extra_args += '-D FUNC' everything is working as expected.

More complex macro definitions need to be surrounded by quotes like in the case of -D "FUNC(rettype, memclass) memclass rettype".

In ctags.vim:137 when calling shellescape the double quotes are escaped ending with -D ""FUNC(rettype, memclass) memclass rettype"" which cannot be interpreted by ctags.

The name of the parser: universal-ctags

The content of input file:

#include <stdio.h>

#define FUNC(rettype) rettype

FUNC(int) fnct(int a);
FUNC(int) fnct(int a)
{
  return a;
}

int main(void)
{
  int a = 1;
  printf("%d\n", fnct(a));
}

The tags output you are not satisfied with(ctags main.c):

!_TAG_FILE_FORMAT   2   /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED   1   /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_OUTPUT_MODE   u-ctags /u-ctags or e-ctags/
!_TAG_PROGRAM_AUTHOR    Universal Ctags Team    //
!_TAG_PROGRAM_NAME  Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL   https://ctags.io/   /official site/
!_TAG_PROGRAM_VERSION   0.0.0   /96d39e4/
FUNC    main.c  /^#define FUNC(/;"  d   file:
fnct    main.c  /^FUNC(int) fnct(int a)$/;" f   typeref:typename:int
main    main.c  /^int main(void)$/;"    f   typeref:typename:int

The tags output you expect(ctags -D "FUNC(rettype) rettype" main.c):

!_TAG_FILE_FORMAT   2   /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED   1   /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_OUTPUT_MODE   u-ctags /u-ctags or e-ctags/
!_TAG_PROGRAM_AUTHOR    Universal Ctags Team    //
!_TAG_PROGRAM_NAME  Universal Ctags /Derived from Exuberant Ctags/
!_TAG_PROGRAM_URL   https://ctags.io/   /official site/
!_TAG_PROGRAM_VERSION   0.0.0   /96d39e4/
FUNC    main.c  /^#define FUNC(/;"  d   file:
fnct    main.c  /^FUNC(int) fnct(int a)$/;" f
main    main.c  /^int main(void)$/;"    f   typeref:typename:int

The version of ctags:

$ ctags --version
Universal Ctags 0.0.0(96d39e4), Copyright (C) 2015 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Jun  7 2018, 22:00:50
  URL: https://ctags.io/
  Optional compiled features: +wildcards, +regex, +iconv, +option-directory

How do you get ctags binary: Building it locally and win32 binary taken from Universal-ctags/ctags-win32 project

CatalinGB commented 6 years ago

Oups... Please ignore my issue as I added to the wrong repo. Meant it for vim-gutentags. :)