1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-26 01:22:12 +03:00

New pgindent.

This commit is contained in:
Bruce Momjian
1998-08-09 04:59:10 +00:00
parent 111b80ce00
commit a08dc16c47
4 changed files with 63 additions and 13 deletions

View File

@ -26,10 +26,12 @@ for FILE
do
cat $FILE |
sed 's;/\* *---;/*---X_X;g' |
# workaround for indent bug with 'else' handling
sed 's;\([} ]\)else[ ]*\(/\*.*\)$;\1else\
\2;g' | # workaround for indent bug
\2;g' |
detab -t4 -qc |
sed 's;^DATA(.*$;/*&*/;' >/tmp/$$a # protect backslashes in DATA()
# protect backslashes in DATA()
sed 's;^DATA(.*$;/*&*/;' >/tmp/$$a
# We get the list of typedef's from /src/tools/find_typedef
indent -bad -bap -bc -bl -d0 -cdb -nce -nfc1 -di12 -i4 -l75 \
@ -792,12 +794,17 @@ do
cat /tmp/$$a |
sed 's;^/\*\(DATA(.*\)\*/$;\1;' |
sed 's;/\*---X_X;/* ---;g' |
sed 's;^static[ ][ ]*;static ;g' | # workaround indent bug
# workaround indent bug
sed 's;^static[ ][ ]*;static ;g' |
sed 's;^}[ ][ ]*/\*;} /*;' |
detab -t8 -qc |
entab -t4 -qc |
sed 's;^\([A-Za-z_][^ ]*\)[ ][ ]*\*$;\1 *;' | # move trailing * in function return type
awk ' { line3 = $0; /* remove un-needed braces around single statements */
# move trailing * in function return type
sed 's;^\([A-Za-z_][^ ]*\)[ ][ ]*\*$;\1 *;' |
# remove un-needed braces around single statements
awk '
{
line3 = $0;
if (skips > 0)
skips--;
if (line1 ~ " *{$" &&
@ -823,9 +830,52 @@ do
if (skips <= 2)
print line2;
}' |
# 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
# like real functions.
awk ' BEGIN {paren_level = 0}
{
if ($0 ~ /^[a-zA-Z_][a-zA-Z_0-9]*[^\(]*$/)
{
saved_len = 0;
saved_lines[++saved_len] = $0;
if ((getline saved_lines[++saved_len]) == 0)
print saved_lines[1];
else
if (saved_lines[saved_len] !~ /^[a-zA-Z_][a-zA-Z_0-9]*\(/ ||
saved_lines[saved_len] ~ /^[a-zA-Z_][a-zA-Z_0-9]*\(.*\)$/ ||
saved_lines[saved_len] ~ /^[a-zA-Z_][a-zA-Z_0-9]*\(.*\);$/)
{
print saved_lines[1];
print saved_lines[2];
}
else
{
while (1)
{
if ((getline saved_lines[++saved_len]) == 0)
break;
if (saved_lines[saved_len] ~ /\);?$/ ||
saved_lines[saved_len] ~ /^[^ ]/ ||
saved_lines[saved_len] ~ /^$/)
break;
}
for (i=1; i <= saved_len; i++)
{
if (i == 1 && saved_lines[saved_len] ~ /\);$/)
{
printf "%s", saved_lines[i];
if (substr(saved_lines[i], length(saved_lines[i]),1) != "*")
printf " ";
}
else print saved_lines[i];
}
}
}
else print $0;
}' |
cat >/tmp/$$ && cat /tmp/$$ >$FILE
done
# The 'for' loop makes these backup files useless
# so delete them
# The 'for' loop makes these backup files useless so delete them
rm -f *a.BAK