Search code examples
cctagsexuberant-ctagsuncrustify

Condense multiline C function prototypes


I have C function prototypes (certain windows api header files) that look like:

int
foo
(
int
a
,
int
*
b
)
;

(they seem to have no coding convention)

which I am trying to programmatically turn into a one-line prototype of the form (or something close to it):

int foo(int a, int * b);

I have looked into programs like ctags ( ctags multi-line C function prototypes ) and into various settings in uncrustify ( http://uncrustify.sourceforge.net/ ) however I haven't been able to make any headway in either. (any insight would be great, or perhaps one of the 385 uncrustify options that I missed does what I want).

Programmatically, I am trying to look for unique markers that signify a function prototype so that I can write a script that will format the code to my liking.

Without using a lexer and a parser this seems like it could get very convoluted very quickly; any suggestions?


Solution

  • run them through indent -kr or astyle --style=kr