aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2001-10-25 19:57:03 +0000
committerBruce Momjian <bruce@momjian.us>2001-10-25 19:57:03 +0000
commit80b9a0043967a3d609eed5770e464c05e98fcd73 (patch)
tree2547200fd58c6f7319661476a56bea23accedb92 /src
parentbac0d2d2cdd80fb396fb78f6ad8fffb437e81819 (diff)
downloadpostgresql-80b9a0043967a3d609eed5770e464c05e98fcd73.tar.gz
postgresql-80b9a0043967a3d609eed5770e464c05e98fcd73.zip
Add blank line before #endif to #endif's at the end of the file.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/tools/pgindent/pgindent24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent
index d939c676bd8..6f843944fd2 100755
--- a/src/tools/pgindent/pgindent
+++ b/src/tools/pgindent/pgindent
@@ -1292,7 +1292,7 @@ int pgindent_func_no_var_fix;\
# pull in #endif comments
sed 's;^#endif[ ][ ]*/\*;#endif /*;' |
# add space after comments that start on tab stops
- sed 's:\([;,)/]\)/\*.*\*/\)$:\1 \2:' |
+ sed 's:\([^ ]\)/\*.*\*/\)$:\1 \2:' |
# work around #else indenting next line if #ifdef defines variables at top
# work around misindenting of function with no variables defined
awk '
@@ -1329,14 +1329,13 @@ int pgindent_func_no_var_fix;\
print line1;
line1 = line2;
line2 = line3;
- line3 = "";
}
END {
if (skips <= 1)
print line1;
if (skips <= 2)
print line2;
- }' |
+ }' |
# remove blank line between opening brace and block comment
awk '
{
@@ -1358,14 +1357,13 @@ int pgindent_func_no_var_fix;\
print line1;
line1 = line2;
line2 = line3;
- line3 = "";
}
END {
if (skips <= 1)
print line1;
if (skips <= 2)
print line2;
- }' |
+ }' |
# remove blank line before #endif
awk ' BEGIN {line1 = ""; line2 = ""; skips = 0}
{
@@ -1383,12 +1381,24 @@ int pgindent_func_no_var_fix;\
if (skips == 0 && NR >= 2)
print line1;
line1 = line2;
- line2 = "";
}
END {
if (skips <= 1)
print line1;
- }' |
+ }' |
+# add blank line before #endif if it is the last line in the file
+ awk ' BEGIN {line1 = ""; line2 = ""}
+ {
+ line2 = $0;
+ if (NR >= 2)
+ print line1;
+ line1 = line2;
+ }
+ END {
+ if (line2 ~ "^#endif")
+ printf "\n";
+ print line1;
+ }' |
# Move prototype names to the same line as return type. Useful for ctags.
# Indent should do this, but it does not. It formats prototypes just
# like real functions.