I need to remove ";" from statements in C which have ";;". Eg:
main()
{
int i;;
int j,k;;
int l;
for(i=0;i<10;;)
{}
}
should become:
main()
{
int i;
int j,k;
int l;
for(i=0;i<10;;)
{}
}
I need to remove ";" from statements in C which have ";;". Eg:
main()
{
int i;;
int j,k;;
int l;
for(i=0;i<10;;)
{}
}
should become:
main()
{
int i;
int j,k;
int l;
for(i=0;i<10;;)
{}
}
Consider using Find & replace command. Any decent text editor has one (Notepad++, KWrite, not to mention Emacs). Search for ;; and replace it with ;.
If you have plenty of code and ;
can happen inside char* values, use regexp :)
EDIT: Fine, you should search for: ;; *\n and then replace it with ;\n.
My first answer was wrong because I missed the ;; in the head of the for loop, which does serve a purpose.
The following perl script will replace all ;; followed by whitespace with a single ;. It will do that for all C files (file extension .c) in the current directory and its subdirectories.
perl -i -p -e 's/;;(\s*)$/;$1/g' `find | grep .c`
Thanks to Sean Bright for fixing my original mistake. (See the comments.)
I just want to point out that the extra ; at the end of line shouldn't really present a problem. You could just leave them there, or you could just use your text editor to search and replace the ones that are extraneous.