int func(a,b){
vs.
int func(a,b)
{
Save this to file "diffclean.awk" and run it as "./diffclean.awk my.diff".
#!/usr/bin/gawk -f
function process_block(str,strp,strm){
regex="[ \t\f\r\n]+";
gsub(regex," ",strp);
gsub(regex," ",strm);
if (strp!=strm){
print str;
}
}
{
if (!block_started) {
if (/^@@/) {
block_started=1;
str=$0;
strp="";
strm="";
}else{
print;
}
next;
}
if (/^diff/) {
process_block(str,strp,strm);
block_started=0;
print;
next;
}
if (/^@@/) {
process_block(str,strp,strm);
str=$0;
strp="";
strm="";
next;
}
str=str "\n" $0;
if (/^-/) strm=strm substr($0,2);
if (/^+/) strp=strp substr($0,2);
}
END{
if (block_started){
process_block(str,strp,strm);
}
}
No comments:
Post a Comment