Is there a way for ctags to handle multiline function prototypes in C?
I've searched around and the --fields=+S
is supposed to do multiline prototypes, but I can't get it to work:
ctags -x --c-kinds=pf --fields=+S file
file:
int
foo(int
x, int y
);
ctags only returns:
foo(int
(Note that the return type is also missing)
Ultimately I would like to get an output similar to
int foo(int x, int y);
or
int foo(int x, int y
is --fields=+S
not the correct way?
Are there part of the ctags fields that I am missing?
Any pointers in general?
If there is not a way to do it in ctags, any recommended programs? (I'm currently looking at uncrustify)
I was unable to find anything with ctags so I wrote a python script to re-arrange my file so that ctags could capture the prototypes.
Note: my code had comments and so much of this takes care with removing them (otherwise they would get in the way of ctags).
Manipulations were done in this order:
# concat to one line
file_str = ''
for line in read_from.readlines():
file_str += line
# remove all /* */ comments
file_str = re.sub('/\*(.|[\r\n])*?\*/', '', file_str)
# remove '//' comments
file_str = re.sub('//.*', '', file_str)
# split on '\n'
file_as_list = file_str.splitlines(True)
# strip everything
for index in range(len(file_as_list)):
file_as_list[index] = file_as_list[index].strip()
# add in newlines where appropriate
for line in file_as_list:
# if the line ends in ';' or '}'
if line.endswith(';') or line.endswith('}'):
# append a newline to the stripped line
write_to.write(line.strip() + '\n')
else:
# append a space to the stripped line
write_to.write(line.strip() + ' ')