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

Commit 876c700

Browse files
committed
Make extern C handling more flexible.
1 parent 149d13d commit 876c700

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/tools/pgindent/pgindent

+8-6
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,14 @@ do
6767
line2 = $0;
6868
if (skips > 0)
6969
skips--;
70-
if (line1 ~ "^extern[ ]*\"C\"" &&
71-
line2 ~ "^{[ ]*$")
70+
if (line1 ~ "^#ifdef[ ]*__cplusplus" &&
71+
line2 ~ "^extern[ ]*\"C\"[ ]*$")
7272
{
73-
# do not print first line
74-
print "/* Open extern \"C\" */";
73+
print line1;
74+
print line2;
75+
if (getline && $0 ~ /^{[ ]*$/)
76+
print "/* Open extern \"C\" */";
77+
else print $0;
7578
line2 = "";
7679
skips = 2;
7780
}
@@ -1490,8 +1493,7 @@ do
14901493
# remove tabs and retab with four spaces
14911494
detab -t8 -qc |
14921495
entab -t4 -qc |
1493-
sed 's;^/\* Open extern \"C\" \*/$;extern "C"\
1494-
{;' |
1496+
sed 's;^/\* Open extern \"C\" \*/$;{;' |
14951497
sed 's;^/\* Close extern \"C\" \*/$;};' |
14961498
sed 's;/\*---X_X;/* ---;g' |
14971499
# workaround indent bug

0 commit comments

Comments
 (0)