// K&R syntax
int foo(a, p)
int a;
char *p;
{
return 0;
}
// ANSI syntax
int foo(int a, char *p)
{
return 0;
}
As you see, in K&R style, the types of variables are declared in new lines instead of in the braces. How to convert a K&R function declaration to an ANSI function declaration automatically? Does anybody know such an easy-to-use tool in Linux?
Since You wanna convert a multiline string, you chould consider perl
you have
and must have
So
or something like it, would do the trick.
It would be easier to tackle down the correct regex to this if you try it out and post in comments the output of
for each of your source files.
You can use cproto or protoize (part of GCC) to generate function prototypes or convert old style (K&R) functions to ANSI format.
1) if you want to create standard C prototypes for a .h file use mkproto.c
You then could also paste over the old K&R code in the C file definition if desired.