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

Commit 1f735c3

Browse files
committed
Add blank lines to pgindent.
1 parent 591b9b0 commit 1f735c3

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/tools/pgindent/pgindent

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
# $PostgreSQL: pgsql/src/tools/pgindent/pgindent,v 1.90 2006/12/27 23:03:52 momjian Exp $
3+
# $PostgreSQL: pgsql/src/tools/pgindent/pgindent,v 1.91 2007/11/15 21:52:39 momjian Exp $
44

55
# Known bugs:
66
#
@@ -47,6 +47,7 @@ do
4747
sed 's;\([} ]\)else[ ]*\(/\*.*[^\*][^/]\)$;\1else\
4848
\2;g' |
4949
detab -t4 -qc |
50+
5051
# work around bug where function that defines no local variables misindents
5152
# switch() case lines and line after #else. Do not do for struct/enum.
5253
awk ' BEGIN {line1 = ""; line2 = ""}
@@ -69,6 +70,7 @@ do
6970
if (NR >= 1)
7071
print line1;
7172
}' |
73+
7274
# prevent indenting of code in 'extern "C"' blocks
7375
awk ' BEGIN {line1 = ""; line2 = ""; skips = 0}
7476
{
@@ -103,8 +105,10 @@ do
103105
if (NR >= 1 && skips <= 1)
104106
print line1;
105107
}' |
108+
106109
# protect backslashes in DATA()
107110
sed 's;^DATA(.*$;/*&*/;' |
111+
108112
# protect wrapping in CATALOG()
109113
sed 's;^CATALOG(.*$;/*&*/;' >/tmp/$$a
110114

@@ -1878,30 +1882,37 @@ do
18781882
-Tz_stream \
18791883
-Tz_streamp \
18801884
/tmp/$$a >/tmp/$$ 2>&1
1885+
18811886
if [ "$?" -ne 0 -o -s /tmp/$$ ]
18821887
then echo
18831888
echo "$FILE"
18841889
cat /tmp/$$
18851890
fi
18861891
cat /tmp/$$a |
1892+
18871893
# restore DATA/CATALOG lines
18881894
sed 's;^/\*\(DATA(.*\)\*/$;\1;' |
18891895
sed 's;^/\*\(CATALOG(.*\)\*/$;\1;' |
1896+
18901897
# remove tabs and retab with four spaces
18911898
detab -t8 -qc |
18921899
entab -t4 -qc |
18931900
sed 's;^/\* Open extern \"C\" \*/$;{;' |
18941901
sed 's;^/\* Close extern \"C\" \*/$;};' |
18951902
sed 's;/\*---X_X;/* ---;g' |
1903+
18961904
# workaround indent bug for 'static'
18971905
sed 's;^static[ ][ ]*;static ;g' |
1906+
18981907
# remove too much indenting after closing brace
18991908
sed 's;^} [ ]*;} ;' |
1909+
19001910
# indent single-line after-'else' comment by only one tab
19011911
sed 's;\([} ]\)else[ ]*\(/\*.*\*/\)[ ]*$;\1else \2;g' |
1912+
19021913
# pull in #endif comments
19031914
sed 's;^#endif[ ][ ]*/\*;#endif /*;' |
1904-
# work around #else indenting next line if #ifdef defines variables at top
1915+
19051916
# work around misindenting of function with no variables defined
19061917
awk '
19071918
{
@@ -1912,10 +1923,13 @@ do
19121923
}
19131924
else print $0;
19141925
}' |
1926+
19151927
# add space after comments that start on tab stops
19161928
sed 's;\([^ ]\)\(/\*.*\*/\)$;\1 \2;' |
1929+
19171930
# move trailing * in function return type
19181931
sed 's;^\([A-Za-z_][^ ]*\)[ ][ ]*\*$;\1 *;' |
1932+
19191933
# remove un-needed braces around single statements
19201934
# Do not use because it uglifies PG_TRY/PG_CATCH blocks and probably
19211935
# isn't needed for general use.
@@ -1945,6 +1959,7 @@ do
19451959
# if (NR >= 1 && skips <= 2)
19461960
# print line2;
19471961
# }' |
1962+
19481963
# remove blank line between opening brace and block comment
19491964
awk '
19501965
{
@@ -1973,6 +1988,7 @@ do
19731988
if (NR >= 1 && skips <= 2)
19741989
print line2;
19751990
}' |
1991+
19761992
# remove trailing blank lines, helps with adding blank before trailing #endif
19771993
awk ' BEGIN {blank_lines = 0;}
19781994
{
@@ -1986,6 +2002,7 @@ do
19862002
print line1;
19872003
}
19882004
}' |
2005+
19892006
# remove blank line before #else, #elif, and #endif
19902007
awk ' BEGIN {line1 = ""; line2 = ""; skips = 0}
19912008
{
@@ -2010,6 +2027,7 @@ do
20102027
if (NR >= 1 && skips <= 1)
20112028
print line1;
20122029
}' |
2030+
20132031
# add blank line before #endif if it is the last line in the file
20142032
awk ' BEGIN {line1 = ""; line2 = ""}
20152033
{
@@ -2023,6 +2041,7 @@ do
20232041
printf "\n";
20242042
print line1;
20252043
}' |
2044+
20262045
# Move prototype names to the same line as return type. Useful for ctags.
20272046
# Indent should do this, but it does not. It formats prototypes just
20282047
# like real functions.
@@ -2066,6 +2085,7 @@ do
20662085
}
20672086
else print $0;
20682087
}' |
2088+
20692089
# fix indenting of typedef caused by __cplusplus in libpq-fe.h
20702090
(
20712091
if echo "$FILE" | grep -q 'libpq-fe.h$'

0 commit comments

Comments
 (0)