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

Commit c29797d

Browse files
committed
Add code to trip trailing newlines in a file.
1 parent 5ef74fe commit c29797d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/tools/pgindent/pgindent

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,19 @@ do
15311531
if (NR >= 1 && skips <= 2)
15321532
print line2;
15331533
}' |
1534+
# remove trailing blank lines, helps with adding blank before trailing #endif
1535+
awk ' BEGIN {blank_lines = 0;}
1536+
{
1537+
line1 = $0;
1538+
if (line1 ~ /^$/)
1539+
blank_lines++;
1540+
else
1541+
{
1542+
for (; blank_lines > 0; blank_lines--)
1543+
printf "\n";
1544+
print line1;
1545+
}
1546+
}' |
15341547
# remove blank line before #endif
15351548
awk ' BEGIN {line1 = ""; line2 = ""; skips = 0}
15361549
{

0 commit comments

Comments
 (0)