Add code to not indent enum, per Tom Lane.

This commit is contained in:
Bruce Momjian 2001-10-26 16:21:13 +00:00
parent 99a9f2f6f4
commit 8c1f4e574b

View File

@ -34,10 +34,24 @@ do
\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 # switch() case lines and line after #else. Do not do with for struct/enum.
sed 's,^{$,{\ awk ' BEGIN {line1 = ""; line2 = ""}
int pgindent_func_no_var_fix;\ {
,g' | line2 = $0;
if (NR >= 2 &&
line2 ~ "^{[ ]*$" &&
line1 !~ "^struct" &&
line1 !~ "^enum" &&
line1 !~ "^typedef")
printf "int pgindent_func_no_var_fix;";
if (NR >= 2)
print line1;
line1 = line2;
}
END {
if (NR >= 1)
print line1;
}' |
# protect backslashes in DATA() # protect backslashes in DATA()
sed 's;^DATA(.*$;/*&*/;' | sed 's;^DATA(.*$;/*&*/;' |
# protect wrapping in CATALOG() # protect wrapping in CATALOG()
@ -1439,7 +1453,7 @@ int pgindent_func_no_var_fix;\
# pull in #endif comments # pull in #endif comments
sed 's;^#endif[ ][ ]*/\*;#endif /*;' | sed 's;^#endif[ ][ ]*/\*;#endif /*;' |
# 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:' |
# work around #else indenting next line if #ifdef defines variables at top # 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 '
@ -1478,9 +1492,9 @@ int pgindent_func_no_var_fix;\
line2 = line3; line2 = line3;
} }
END { END {
if (skips <= 1) if (NR > 1 && skips <= 1)
print line1; print line1;
if (skips <= 2) if (NR > 2 && skips <= 2)
print line2; print line2;
}' | }' |
# remove blank line between opening brace and block comment # remove blank line between opening brace and block comment
@ -1506,9 +1520,9 @@ int pgindent_func_no_var_fix;\
line2 = line3; line2 = line3;
} }
END { END {
if (skips <= 1) if (NR > 1 && skips <= 1)
print line1; print line1;
if (skips <= 2) if (NR > 2 && skips <= 2)
print line2; print line2;
}' | }' |
# remove blank line before #endif # remove blank line before #endif
@ -1530,7 +1544,7 @@ int pgindent_func_no_var_fix;\
line1 = line2; line1 = line2;
} }
END { END {
if (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
@ -1542,7 +1556,7 @@ int pgindent_func_no_var_fix;\
line1 = line2; line1 = line2;
} }
END { END {
if (line2 ~ "^#endif") if (NR > 1 && line2 ~ "^#endif")
printf "\n"; printf "\n";
print line1; print line1;
}' | }' |