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

Commit e7f47ed

Browse files
committed
Pgindent fixes for Tom, mostly indenting problems.
1 parent 66e9ee7 commit e7f47ed

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/tools/pgindent/pgindent

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ do
3333
sed 's;\([} ]\)else[ ]*\(/\*.*\)$;\1else\
3434
\2;g' |
3535
detab -t4 -qc |
36+
# work around bug where function that defines no local variables misindents
37+
# switch() case lines and line after #else
38+
sed 's,^{$,{\
39+
int pgindent_func_no_var_fix;\
40+
,g' |
3641
# protect backslashes in DATA()
3742
sed 's;^DATA(.*$;/*&*/;' >/tmp/$$a
3843

@@ -1309,7 +1314,21 @@ do
13091314
# workaround indent bug
13101315
sed 's;^static[ ][ ]*;static ;g' |
13111316
sed 's;^}[ ][ ]*/\*;} /*;' |
1317+
# pull in #endif comments
13121318
sed 's;^#endif[ ][ ]*/\*;#endif /*;' |
1319+
# add space after comments that start on tab stops
1320+
sed 's,;\(/\*.*\*/\)$,; \1,' |
1321+
# work around #else indenting next line if #ifdef defines variables at top
1322+
# work around case misindenting function has no variables defined
1323+
awk '
1324+
{
1325+
if ($0 ~ "^[ ]*int[ ]*pgindent_func_no_var_fix;")
1326+
{
1327+
if (getline && $0 != "")
1328+
print $0;
1329+
}
1330+
else print $0;
1331+
}' |
13131332
detab -t8 -qc |
13141333
entab -t4 -qc |
13151334
# move trailing * in function return type
@@ -1373,6 +1392,30 @@ do
13731392
if (skips <= 2)
13741393
print line2;
13751394
}' |
1395+
# remove blank line before #endif
1396+
awk '
1397+
{
1398+
line2 = $0;
1399+
if (skips > 0)
1400+
skips--;
1401+
if (line1 ~ "^$" &&
1402+
line2 ~ "^#endif")
1403+
{
1404+
print line2;
1405+
line1 = "";
1406+
line2 = "";
1407+
skips = 2;
1408+
}
1409+
else
1410+
if (skips == 0 && NR >= 2)
1411+
print line1;
1412+
line1 = line2;
1413+
line2 = "";
1414+
}
1415+
END {
1416+
if (skips <= 1)
1417+
print line1;
1418+
}' |
13761419
# Move prototype names to the same line as return type. Useful for ctags.
13771420
# Indent should do this, but it does not. It formats prototypes just
13781421
# like real functions.

0 commit comments

Comments
 (0)