From c29797deeb5dfca61b8959344b682b4c32fe53a1 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sat, 27 Oct 2001 13:54:45 +0000 Subject: [PATCH] Add code to trip trailing newlines in a file. --- src/tools/pgindent/pgindent | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent index 614d93ae42..5321876d8a 100755 --- a/src/tools/pgindent/pgindent +++ b/src/tools/pgindent/pgindent @@ -1531,6 +1531,19 @@ do if (NR >= 1 && skips <= 2) print line2; }' | +# remove trailing blank lines, helps with adding blank before trailing #endif + awk ' BEGIN {blank_lines = 0;} + { + line1 = $0; + if (line1 ~ /^$/) + blank_lines++; + else + { + for (; blank_lines > 0; blank_lines--) + printf "\n"; + print line1; + } + }' | # remove blank line before #endif awk ' BEGIN {line1 = ""; line2 = ""; skips = 0} { -- 2.40.0