mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-15 08:20:16 +08:00
Add code to not indent enum, per Tom Lane.
This commit is contained in:
parent
99a9f2f6f4
commit
8c1f4e574b
@ -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()
|
||||||
@ -1277,153 +1291,153 @@ int pgindent_func_no_var_fix;\
|
|||||||
-Tyy_state_type \
|
-Tyy_state_type \
|
||||||
-Tz_stream \
|
-Tz_stream \
|
||||||
-Tz_streamp \
|
-Tz_streamp \
|
||||||
-T BOOKMARK \
|
-TBOOKMARK \
|
||||||
-T BOOL \
|
-TBOOL \
|
||||||
-T BYTE \
|
-TBYTE \
|
||||||
-T BindInfoClass \
|
-TBindInfoClass \
|
||||||
-T COL_INFO \
|
-TCOL_INFO \
|
||||||
-T CONN_Status \
|
-TCONN_Status \
|
||||||
-T ColumnInfoClass \
|
-TColumnInfoClass \
|
||||||
-T ConnInfo \
|
-TConnInfo \
|
||||||
-T ConnectionClass \
|
-TConnectionClass \
|
||||||
-T DATE_STRUCT \
|
-TDATE_STRUCT \
|
||||||
-T DWORD \
|
-TDWORD \
|
||||||
-T DataSourceToDriverProc \
|
-TDataSourceToDriverProc \
|
||||||
-T DriverToDataSourceProc \
|
-TDriverToDataSourceProc \
|
||||||
-T EnvironmentClass \
|
-TEnvironmentClass \
|
||||||
-T FIELD_INFO \
|
-TFIELD_INFO \
|
||||||
-T FILE \
|
-TFILE \
|
||||||
-T GLOBAL_VALUES \
|
-TGLOBAL_VALUES \
|
||||||
-T HDBC \
|
-THDBC \
|
||||||
-T HENV \
|
-THENV \
|
||||||
-T HSTMT \
|
-THSTMT \
|
||||||
-T HWND \
|
-THWND \
|
||||||
-T LO_ARG \
|
-TLO_ARG \
|
||||||
-T LPARAM \
|
-TLPARAM \
|
||||||
-T Oid \
|
-TOid \
|
||||||
-T PTR \
|
-TPTR \
|
||||||
-T ParameterInfoClass \
|
-TParameterInfoClass \
|
||||||
-T ProtocolVersion \
|
-TProtocolVersion \
|
||||||
-T QResultClass \
|
-TQResultClass \
|
||||||
-T QueryInfo \
|
-TQueryInfo \
|
||||||
-T QueryResultCode \
|
-TQueryResultCode \
|
||||||
-T RETCODE \
|
-TRETCODE \
|
||||||
-T SDOUBLE \
|
-TSDOUBLE \
|
||||||
-T SDWORD \
|
-TSDWORD \
|
||||||
-T SFLOAT \
|
-TSFLOAT \
|
||||||
-T SIMPLE_TIME \
|
-TSIMPLE_TIME \
|
||||||
-T SQLBIGINT \
|
-TSQLBIGINT \
|
||||||
-T SQLCHAR \
|
-TSQLCHAR \
|
||||||
-T SQLDOUBLE \
|
-TSQLDOUBLE \
|
||||||
-T SQLFLOAT \
|
-TSQLFLOAT \
|
||||||
-T SQLGUID \
|
-TSQLGUID \
|
||||||
-T SQLINTEGER \
|
-TSQLINTEGER \
|
||||||
-T SQLINTERVAL \
|
-TSQLINTERVAL \
|
||||||
-T SQLREAL \
|
-TSQLREAL \
|
||||||
-T SQLSCHAR \
|
-TSQLSCHAR \
|
||||||
-T SQLSMALLINT \
|
-TSQLSMALLINT \
|
||||||
-T SQLUBIGINT \
|
-TSQLUBIGINT \
|
||||||
-T SQLUINTEGER \
|
-TSQLUINTEGER \
|
||||||
-T SQLUSMALLINT \
|
-TSQLUSMALLINT \
|
||||||
-T SQL_DATE_STRUCT \
|
-TSQL_DATE_STRUCT \
|
||||||
-T SQL_DAY_SECOND_STRUCT \
|
-TSQL_DAY_SECOND_STRUCT \
|
||||||
-T SQL_INTERVAL_STRUCT \
|
-TSQL_INTERVAL_STRUCT \
|
||||||
-T SQL_TIMESTAMP_STRUCT \
|
-TSQL_TIMESTAMP_STRUCT \
|
||||||
-T SQL_TIME_STRUCT \
|
-TSQL_TIME_STRUCT \
|
||||||
-T SQL_YEAR_MONTH_STRUCT \
|
-TSQL_YEAR_MONTH_STRUCT \
|
||||||
-T SSHOR \
|
-TSSHOR \
|
||||||
-T STMT_Status \
|
-TSTMT_Status \
|
||||||
-T SWORD \
|
-TSWORD \
|
||||||
-T SocketClass \
|
-TSocketClass \
|
||||||
-T StartupPacket \
|
-TStartupPacket \
|
||||||
-T StartupPacket6_2 \
|
-TStartupPacket6_2 \
|
||||||
-T StatementClass \
|
-TStatementClass \
|
||||||
-T StatementOptions \
|
-TStatementOptions \
|
||||||
-T TABLE_INFO \
|
-TTABLE_INFO \
|
||||||
-T TIMESTAMP_STRUCT \
|
-TTIMESTAMP_STRUCT \
|
||||||
-T TIME_STRUCT \
|
-TTIME_STRUCT \
|
||||||
-T TupleField \
|
-TTupleField \
|
||||||
-T TupleListClass \
|
-TTupleListClass \
|
||||||
-T TupleNode \
|
-TTupleNode \
|
||||||
-T UCHAR \
|
-TUCHAR \
|
||||||
-T UDWORD \
|
-TUDWORD \
|
||||||
-T UWORD \
|
-TUWORD \
|
||||||
-T WORD \
|
-TWORD \
|
||||||
-T WPARAM \
|
-TWPARAM \
|
||||||
-T _LIB_VERSION_TYPE \
|
-T_LIB_VERSION_TYPE \
|
||||||
-T _RuneEntry \
|
-T_RuneEntry \
|
||||||
-T _RuneLocale \
|
-T_RuneLocale \
|
||||||
-T _RuneRange \
|
-T_RuneRange \
|
||||||
-T caddr_t \
|
-Tcaddr_t \
|
||||||
-T char \
|
-Tchar \
|
||||||
-T clock_t \
|
-Tclock_t \
|
||||||
-T clockid_t \
|
-Tclockid_t \
|
||||||
-T daddr_t \
|
-Tdaddr_t \
|
||||||
-T dev_t \
|
-Tdev_t \
|
||||||
-T div_t \
|
-Tdiv_t \
|
||||||
-T double \
|
-Tdouble \
|
||||||
-T fd_mask \
|
-Tfd_mask \
|
||||||
-T fd_set \
|
-Tfd_set \
|
||||||
-T fixpt_t \
|
-Tfixpt_t \
|
||||||
-T float \
|
-Tfloat \
|
||||||
-T fpos_t \
|
-Tfpos_t \
|
||||||
-T gid_t \
|
-Tgid_t \
|
||||||
-T in_addr_t \
|
-Tin_addr_t \
|
||||||
-T in_port_t \
|
-Tin_port_t \
|
||||||
-T ino_t \
|
-Tino_t \
|
||||||
-T int \
|
-Tint \
|
||||||
-T int16_t \
|
-Tint16_t \
|
||||||
-T int16m_t \
|
-Tint16m_t \
|
||||||
-T int32_t \
|
-Tint32_t \
|
||||||
-T int32m_t \
|
-Tint32m_t \
|
||||||
-T int64_t \
|
-Tint64_t \
|
||||||
-T int64m_t \
|
-Tint64m_t \
|
||||||
-T int8_t \
|
-Tint8_t \
|
||||||
-T int8m_t \
|
-Tint8m_t \
|
||||||
-T key_t \
|
-Tkey_t \
|
||||||
-T ldiv_t \
|
-Tldiv_t \
|
||||||
-T mode_t \
|
-Tmode_t \
|
||||||
-T nlink_t \
|
-Tnlink_t \
|
||||||
-T off_t \
|
-Toff_t \
|
||||||
-T pid_t \
|
-Tpid_t \
|
||||||
-T q128_t \
|
-Tq128_t \
|
||||||
-T qaddr_t \
|
-Tqaddr_t \
|
||||||
-T quad_t \
|
-Tquad_t \
|
||||||
-T register_t \
|
-Tregister_t \
|
||||||
-T rune_t \
|
-Trune_t \
|
||||||
-T sa_family_t \
|
-Tsa_family_t \
|
||||||
-T segsz_t \
|
-Tsegsz_t \
|
||||||
-T sig_atomic_t \
|
-Tsig_atomic_t \
|
||||||
-T sig_t \
|
-Tsig_t \
|
||||||
-T sigset_t \
|
-Tsigset_t \
|
||||||
-T size_t \
|
-Tsize_t \
|
||||||
-T slock_t \
|
-Tslock_t \
|
||||||
-T socklen_t \
|
-Tsocklen_t \
|
||||||
-T ssize_t \
|
-Tssize_t \
|
||||||
-T stack_t \
|
-Tstack_t \
|
||||||
-T swblk_t \
|
-Tswblk_t \
|
||||||
-T time_t \
|
-Ttime_t \
|
||||||
-T u_char \
|
-Tu_char \
|
||||||
-T u_int \
|
-Tu_int \
|
||||||
-T u_int16_t \
|
-Tu_int16_t \
|
||||||
-T u_int16m_t \
|
-Tu_int16m_t \
|
||||||
-T u_int32_t \
|
-Tu_int32_t \
|
||||||
-T u_int32m_t \
|
-Tu_int32m_t \
|
||||||
-T u_int64_t \
|
-Tu_int64_t \
|
||||||
-T u_int64m_t \
|
-Tu_int64m_t \
|
||||||
-T u_int8_t \
|
-Tu_int8_t \
|
||||||
-T u_int8m_t \
|
-Tu_int8m_t \
|
||||||
-T u_long \
|
-Tu_long \
|
||||||
-T u_quad_t \
|
-Tu_quad_t \
|
||||||
-T u_short \
|
-Tu_short \
|
||||||
-T uid_t \
|
-Tuid_t \
|
||||||
-T uint \
|
-Tuint \
|
||||||
-T ushort \
|
-Tushort \
|
||||||
-T va_list \
|
-Tva_list \
|
||||||
-T vm_offset_t \
|
-Tvm_offset_t \
|
||||||
-T vm_size_t \
|
-Tvm_size_t \
|
||||||
-T void \
|
-Tvoid \
|
||||||
-T wchar_t \
|
-Twchar_t \
|
||||||
/tmp/$$a >/tmp/$$ 2>&1
|
/tmp/$$a >/tmp/$$ 2>&1
|
||||||
if [ "$?" -ne 0 -o -s /tmp/$$ ]
|
if [ "$?" -ne 0 -o -s /tmp/$$ ]
|
||||||
then echo "$FILE"
|
then echo "$FILE"
|
||||||
@ -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 '
|
||||||
@ -1458,7 +1472,7 @@ int pgindent_func_no_var_fix;\
|
|||||||
sed 's;^\([A-Za-z_][^ ]*\)[ ][ ]*\*$;\1 *;' |
|
sed 's;^\([A-Za-z_][^ ]*\)[ ][ ]*\*$;\1 *;' |
|
||||||
# remove un-needed braces around single statements
|
# remove un-needed braces around single statements
|
||||||
awk '
|
awk '
|
||||||
{
|
{
|
||||||
line3 = $0;
|
line3 = $0;
|
||||||
if (skips > 0)
|
if (skips > 0)
|
||||||
skips--;
|
skips--;
|
||||||
@ -1478,14 +1492,14 @@ 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
|
||||||
awk '
|
awk '
|
||||||
{
|
{
|
||||||
line3 = $0;
|
line3 = $0;
|
||||||
if (skips > 0)
|
if (skips > 0)
|
||||||
skips--;
|
skips--;
|
||||||
@ -1506,14 +1520,14 @@ 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
|
||||||
awk ' BEGIN {line1 = ""; line2 = ""; skips = 0}
|
awk ' BEGIN {line1 = ""; line2 = ""; skips = 0}
|
||||||
{
|
{
|
||||||
line2 = $0;
|
line2 = $0;
|
||||||
if (skips > 0)
|
if (skips > 0)
|
||||||
skips--;
|
skips--;
|
||||||
@ -1530,19 +1544,19 @@ 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
|
||||||
awk ' BEGIN {line1 = ""; line2 = ""}
|
awk ' BEGIN {line1 = ""; line2 = ""}
|
||||||
{
|
{
|
||||||
line2 = $0;
|
line2 = $0;
|
||||||
if (NR >= 2)
|
if (NR >= 2)
|
||||||
print line1;
|
print line1;
|
||||||
line1 = line2;
|
line1 = line2;
|
||||||
}
|
}
|
||||||
END {
|
END {
|
||||||
if (line2 ~ "^#endif")
|
if (NR > 1 && line2 ~ "^#endif")
|
||||||
printf "\n";
|
printf "\n";
|
||||||
print line1;
|
print line1;
|
||||||
}' |
|
}' |
|
||||||
|
Loading…
Reference in New Issue
Block a user