Skip to content

Commit 7accb29

Browse files
committed
Clean up pgindent handling of comments after 'else' by only moving
multi-line comments to the next line.
1 parent 72619f8 commit 7accb29

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/tools/pgindent/pgindent

Lines changed: 11 additions & 5 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.89 2006/10/04 00:02:10 momjian Exp $
3+
# $PostgreSQL: pgsql/src/tools/pgindent/pgindent,v 1.90 2006/12/27 23:03:52 momjian Exp $
44

55
# Known bugs:
66
#
@@ -40,9 +40,12 @@ do
4040
# mark some comments for special treatment later
4141
sed 's;/\* *---;/*---X_X;g' |
4242
# workaround for indent bug with 'else' handling
43-
# indent comment so BSD indent will move it
44-
sed 's;\([} ]\)else[ ]*\(/\*.*\)$;\1else\
45-
\2;g' |
43+
# trim trailing space after single-line after-'else' comment
44+
# so next test can be done easily
45+
sed 's;\([} ]\)else[ ]*\(/\*.*\*/\)[ ]*$;\1else \2;g' |
46+
# indent multi-line after-'else' comment so BSD indent will move it properly
47+
sed 's;\([} ]\)else[ ]*\(/\*.*[^\*][^/]\)$;\1else\
48+
\2;g' |
4649
detab -t4 -qc |
4750
# work around bug where function that defines no local variables misindents
4851
# switch() case lines and line after #else. Do not do for struct/enum.
@@ -1890,9 +1893,12 @@ do
18901893
sed 's;^/\* Open extern \"C\" \*/$;{;' |
18911894
sed 's;^/\* Close extern \"C\" \*/$;};' |
18921895
sed 's;/\*---X_X;/* ---;g' |
1893-
# workaround indent bug
1896+
# workaround indent bug for 'static'
18941897
sed 's;^static[ ][ ]*;static ;g' |
1898+
# remove too much indenting after closing brace
18951899
sed 's;^} [ ]*;} ;' |
1900+
# indent single-line after-'else' comment by only one tab
1901+
sed 's;\([} ]\)else[ ]*\(/\*.*\*/\)[ ]*$;\1else \2;g' |
18961902
# pull in #endif comments
18971903
sed 's;^#endif[ ][ ]*/\*;#endif /*;' |
18981904
# work around #else indenting next line if #ifdef defines variables at top

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy