Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
1f735c32
Commit
1f735c32
authored
Nov 15, 2007
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add blank lines to pgindent.
parent
591b9b09
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
+22
-2
src/tools/pgindent/pgindent
src/tools/pgindent/pgindent
+22
-2
No files found.
src/tools/pgindent/pgindent
View file @
1f735c32
#!/bin/sh
#!/bin/sh
# $PostgreSQL: pgsql/src/tools/pgindent/pgindent,v 1.9
0 2006/12/27 23:03:52
momjian Exp $
# $PostgreSQL: pgsql/src/tools/pgindent/pgindent,v 1.9
1 2007/11/15 21:52:39
momjian Exp $
# Known bugs:
# Known bugs:
#
#
...
@@ -47,6 +47,7 @@ do
...
@@ -47,6 +47,7 @@ do
sed
's;\([} ]\)else[ ]*\(/\*.*[^\*][^/]\)$;\1else\
sed
's;\([} ]\)else[ ]*\(/\*.*[^\*][^/]\)$;\1else\
\2;g'
|
\2;g'
|
detab
-t4
-qc
|
detab
-t4
-qc
|
# work around bug where function that defines no local variables misindents
# work around bug where function that defines no local variables misindents
# switch() case lines and line after #else. Do not do for struct/enum.
# switch() case lines and line after #else. Do not do for struct/enum.
awk
' BEGIN {line1 = ""; line2 = ""}
awk
' BEGIN {line1 = ""; line2 = ""}
...
@@ -69,6 +70,7 @@ do
...
@@ -69,6 +70,7 @@ do
if (NR >= 1)
if (NR >= 1)
print line1;
print line1;
}'
|
}'
|
# prevent indenting of code in 'extern "C"' blocks
# prevent indenting of code in 'extern "C"' blocks
awk
' BEGIN {line1 = ""; line2 = ""; skips = 0}
awk
' BEGIN {line1 = ""; line2 = ""; skips = 0}
{
{
...
@@ -103,8 +105,10 @@ do
...
@@ -103,8 +105,10 @@ do
if (NR >= 1 && skips <= 1)
if (NR >= 1 && skips <= 1)
print line1;
print line1;
}'
|
}'
|
# protect backslashes in DATA()
# protect backslashes in DATA()
sed
's;^DATA(.*$;/*&*/;'
|
sed
's;^DATA(.*$;/*&*/;'
|
# protect wrapping in CATALOG()
# protect wrapping in CATALOG()
sed
's;^CATALOG(.*$;/*&*/;'
>
/tmp/
$$
a
sed
's;^CATALOG(.*$;/*&*/;'
>
/tmp/
$$
a
...
@@ -1878,30 +1882,37 @@ do
...
@@ -1878,30 +1882,37 @@ do
-Tz_stream
\
-Tz_stream
\
-Tz_streamp
\
-Tz_streamp
\
/tmp/
$$
a
>
/tmp/
$$
2>&1
/tmp/
$$
a
>
/tmp/
$$
2>&1
if
[
"
$?
"
-ne
0
-o
-s
/tmp/
$$
]
if
[
"
$?
"
-ne
0
-o
-s
/tmp/
$$
]
then
echo
then
echo
echo
"
$FILE
"
echo
"
$FILE
"
cat
/tmp/
$$
cat
/tmp/
$$
fi
fi
cat
/tmp/
$$
a |
cat
/tmp/
$$
a |
# restore DATA/CATALOG lines
# restore DATA/CATALOG lines
sed
's;^/\*\(DATA(.*\)\*/$;\1;'
|
sed
's;^/\*\(DATA(.*\)\*/$;\1;'
|
sed
's;^/\*\(CATALOG(.*\)\*/$;\1;'
|
sed
's;^/\*\(CATALOG(.*\)\*/$;\1;'
|
# remove tabs and retab with four spaces
# remove tabs and retab with four spaces
detab
-t8
-qc
|
detab
-t8
-qc
|
entab
-t4
-qc
|
entab
-t4
-qc
|
sed
's;^/\* Open extern \"C\" \*/$;{;'
|
sed
's;^/\* Open extern \"C\" \*/$;{;'
|
sed
's;^/\* Close extern \"C\" \*/$;};'
|
sed
's;^/\* Close extern \"C\" \*/$;};'
|
sed
's;/\*---X_X;/* ---;g'
|
sed
's;/\*---X_X;/* ---;g'
|
# workaround indent bug for 'static'
# workaround indent bug for 'static'
sed
's;^static[ ][ ]*;static ;g'
|
sed
's;^static[ ][ ]*;static ;g'
|
# remove too much indenting after closing brace
# remove too much indenting after closing brace
sed
's;^} [ ]*;} ;'
|
sed
's;^} [ ]*;} ;'
|
# indent single-line after-'else' comment by only one tab
# indent single-line after-'else' comment by only one tab
sed
's;\([} ]\)else[ ]*\(/\*.*\*/\)[ ]*$;\1else \2;g'
|
sed
's;\([} ]\)else[ ]*\(/\*.*\*/\)[ ]*$;\1else \2;g'
|
# pull in #endif comments
# pull in #endif comments
sed
's;^#endif[ ][ ]*/\*;#endif /*;'
|
sed
's;^#endif[ ][ ]*/\*;#endif /*;'
|
# work around #else indenting next line if #ifdef defines variables at top
# work around misindenting of function with no variables defined
# work around misindenting of function with no variables defined
awk
'
awk
'
{
{
...
@@ -1912,10 +1923,13 @@ do
...
@@ -1912,10 +1923,13 @@ do
}
}
else print $0;
else print $0;
}'
|
}'
|
# add space after comments that start on tab stops
# add space after comments that start on tab stops
sed
's;\([^ ]\)\(/\*.*\*/\)$;\1 \2;'
|
sed
's;\([^ ]\)\(/\*.*\*/\)$;\1 \2;'
|
# move trailing * in function return type
# move trailing * in function return type
sed
's;^\([A-Za-z_][^ ]*\)[ ][ ]*\*$;\1 *;'
|
sed
's;^\([A-Za-z_][^ ]*\)[ ][ ]*\*$;\1 *;'
|
# remove un-needed braces around single statements
# remove un-needed braces around single statements
# Do not use because it uglifies PG_TRY/PG_CATCH blocks and probably
# Do not use because it uglifies PG_TRY/PG_CATCH blocks and probably
# isn't needed for general use.
# isn't needed for general use.
...
@@ -1945,6 +1959,7 @@ do
...
@@ -1945,6 +1959,7 @@ do
# if (NR >= 1 && skips <= 2)
# if (NR >= 1 && skips <= 2)
# print line2;
# print line2;
# }' |
# }' |
# remove blank line between opening brace and block comment
# remove blank line between opening brace and block comment
awk
'
awk
'
{
{
...
@@ -1973,6 +1988,7 @@ do
...
@@ -1973,6 +1988,7 @@ do
if (NR >= 1 && skips <= 2)
if (NR >= 1 && skips <= 2)
print line2;
print line2;
}'
|
}'
|
# remove trailing blank lines, helps with adding blank before trailing #endif
# remove trailing blank lines, helps with adding blank before trailing #endif
awk
' BEGIN {blank_lines = 0;}
awk
' BEGIN {blank_lines = 0;}
{
{
...
@@ -1986,6 +2002,7 @@ do
...
@@ -1986,6 +2002,7 @@ do
print line1;
print line1;
}
}
}'
|
}'
|
# remove blank line before #else, #elif, and #endif
# remove blank line before #else, #elif, and #endif
awk
' BEGIN {line1 = ""; line2 = ""; skips = 0}
awk
' BEGIN {line1 = ""; line2 = ""; skips = 0}
{
{
...
@@ -2010,6 +2027,7 @@ do
...
@@ -2010,6 +2027,7 @@ do
if (NR >= 1 && skips <= 1)
if (NR >= 1 && skips <= 1)
print line1;
print line1;
}'
|
}'
|
# add blank line before #endif if it is the last line in the file
# add blank line before #endif if it is the last line in the file
awk
' BEGIN {line1 = ""; line2 = ""}
awk
' BEGIN {line1 = ""; line2 = ""}
{
{
...
@@ -2023,6 +2041,7 @@ do
...
@@ -2023,6 +2041,7 @@ do
printf "\n";
printf "\n";
print line1;
print line1;
}'
|
}'
|
# Move prototype names to the same line as return type. Useful for ctags.
# 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
# Indent should do this, but it does not. It formats prototypes just
# like real functions.
# like real functions.
...
@@ -2066,6 +2085,7 @@ do
...
@@ -2066,6 +2085,7 @@ do
}
}
else print $0;
else print $0;
}'
|
}'
|
# fix indenting of typedef caused by __cplusplus in libpq-fe.h
# fix indenting of typedef caused by __cplusplus in libpq-fe.h
(
(
if
echo
"
$FILE
"
|
grep
-q
'libpq-fe.h$'
if
echo
"
$FILE
"
|
grep
-q
'libpq-fe.h$'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment