|
33 | 33 | sed 's;\([} ]\)else[ ]*\(/\*.*\)$;\1else\
|
34 | 34 | \2;g' |
|
35 | 35 | 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' | |
36 | 41 | # protect backslashes in DATA()
|
37 | 42 | sed 's;^DATA(.*$;/*&*/;' >/tmp/$$a
|
38 | 43 |
|
@@ -1309,7 +1314,21 @@ do
|
1309 | 1314 | # workaround indent bug
|
1310 | 1315 | sed 's;^static[ ][ ]*;static ;g' |
|
1311 | 1316 | sed 's;^}[ ][ ]*/\*;} /*;' |
|
| 1317 | +# pull in #endif comments |
1312 | 1318 | 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 | + }' | |
1313 | 1332 | detab -t8 -qc |
|
1314 | 1333 | entab -t4 -qc |
|
1315 | 1334 | # move trailing * in function return type
|
@@ -1373,6 +1392,30 @@ do
|
1373 | 1392 | if (skips <= 2)
|
1374 | 1393 | print line2;
|
1375 | 1394 | }' |
|
| 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 | + }' | |
1376 | 1419 | # Move prototype names to the same line as return type. Useful for ctags.
|
1377 | 1420 | # Indent should do this, but it does not. It formats prototypes just
|
1378 | 1421 | # like real functions.
|
|
0 commit comments