diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent index 8b4be4ade1..33b6e06072 100755 --- a/src/tools/pgindent/pgindent +++ b/src/tools/pgindent/pgindent @@ -797,6 +797,32 @@ do detab -t8 -qc | entab -t4 -qc | sed 's;^\([A-Za-z_][^ ]*\)[ ][ ]*\*$;\1 *;' | # move trailing * in function return type + awk ' { line3 = $0; /* remove un-needed braces around single statements */ + if (skips > 0) + skips--; + if (line1 ~ " *{$" && + line2 ~ " *[^;{}]*;$" && + line3 ~ " *}$") + { + print line2; + line1 = ""; + line2 = ""; + line3 = ""; + skips = 3; + } + else + if (skips == 0 && NR >= 3) + print line1; + line1 = line2; + line2 = line3; + line3 = ""; + } + END { + if (skips <= 1) + print line1; + if (skips <= 2) + print line2; + }' | cat >/tmp/$$ && cat /tmp/$$ >$FILE done