Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 56bdbe1

Browse files
committed
Add remove extra braces code to pgindent.
1 parent 6bd323c commit 56bdbe1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/tools/pgindent/pgindent

+26
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,32 @@ do
797797
detab -t8 -qc |
798798
entab -t4 -qc |
799799
sed 's;^\([A-Za-z_][^ ]*\)[ ][ ]*\*$;\1 *;' | # move trailing * in function return type
800+
awk ' { line3 = $0; /* remove un-needed braces around single statements */
801+
if (skips > 0)
802+
skips--;
803+
if (line1 ~ " *{$" &&
804+
line2 ~ " *[^;{}]*;$" &&
805+
line3 ~ " *}$")
806+
{
807+
print line2;
808+
line1 = "";
809+
line2 = "";
810+
line3 = "";
811+
skips = 3;
812+
}
813+
else
814+
if (skips == 0 && NR >= 3)
815+
print line1;
816+
line1 = line2;
817+
line2 = line3;
818+
line3 = "";
819+
}
820+
END {
821+
if (skips <= 1)
822+
print line1;
823+
if (skips <= 2)
824+
print line2;
825+
}' |
800826
cat >/tmp/$$ && cat /tmp/$$ >$FILE
801827
done
802828

0 commit comments

Comments
 (0)