1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-26 23:43:30 +03:00

Phase 2 of pgindent updates.

Change pg_bsd_indent to follow upstream rules for placement of comments
to the right of code, and remove pgindent hack that caused comments
following #endif to not obey the general rule.

Commit e3860ffa4d wasn't actually using
the published version of pg_bsd_indent, but a hacked-up version that
tried to minimize the amount of movement of comments to the right of
code.  The situation of interest is where such a comment has to be
moved to the right of its default placement at column 33 because there's
code there.  BSD indent has always moved right in units of tab stops
in such cases --- but in the previous incarnation, indent was working
in 8-space tab stops, while now it knows we use 4-space tabs.  So the
net result is that in about half the cases, such comments are placed
one tab stop left of before.  This is better all around: it leaves
more room on the line for comment text, and it means that in such
cases the comment uniformly starts at the next 4-space tab stop after
the code, rather than sometimes one and sometimes two tabs after.

Also, ensure that comments following #endif are indented the same
as comments following other preprocessor commands such as #else.
That inconsistency turns out to have been self-inflicted damage
from a poorly-thought-through post-indent "fixup" in pgindent.

This patch is much less interesting than the first round of indent
changes, but also bulkier, so I thought it best to separate the effects.

Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
This commit is contained in:
Tom Lane
2017-06-21 15:18:54 -04:00
parent f669c09989
commit c7b8998ebb
1107 changed files with 3433 additions and 3514 deletions

View File

@@ -103,7 +103,7 @@ static struct pam_conv pam_passw_conv = {
static char *pam_passwd = NULL; /* Workaround for Solaris 2.6 brokenness */
static Port *pam_port_cludge; /* Workaround for passing "Port *port" into
* pam_passwd_conv_proc */
#endif /* USE_PAM */
#endif /* USE_PAM */
/*----------------------------------------------------------------
@@ -114,7 +114,7 @@ static Port *pam_port_cludge; /* Workaround for passing "Port *port" into
#include <bsd_auth.h>
static int CheckBSDAuth(Port *port, char *user);
#endif /* USE_BSD_AUTH */
#endif /* USE_BSD_AUTH */
/*----------------------------------------------------------------
@@ -141,7 +141,7 @@ ULONG (*__ldap_start_tls_sA) (
#endif
static int CheckLDAPAuth(Port *port);
#endif /* USE_LDAP */
#endif /* USE_LDAP */
/*----------------------------------------------------------------
* Cert authentication
@@ -172,7 +172,7 @@ bool pg_krb_caseins_users;
#endif
static int pg_GSS_recvauth(Port *port);
#endif /* ENABLE_GSS */
#endif /* ENABLE_GSS */
/*----------------------------------------------------------------
@@ -558,7 +558,7 @@ ClientAuthentication(Port *port)
status = CheckPAMAuth(port, port->user_name, "");
#else
Assert(false);
#endif /* USE_PAM */
#endif /* USE_PAM */
break;
case uaBSD:
@@ -566,7 +566,7 @@ ClientAuthentication(Port *port)
status = CheckBSDAuth(port, port->user_name);
#else
Assert(false);
#endif /* USE_BSD_AUTH */
#endif /* USE_BSD_AUTH */
break;
case uaLDAP:
@@ -671,7 +671,7 @@ recv_password_packet(Port *port)
}
initStringInfo(&buf);
if (pq_getmessage(&buf, 1000)) /* receive password */
if (pq_getmessage(&buf, 1000)) /* receive password */
{
/* EOF - pq_getmessage already logged a suitable message */
pfree(buf.data);
@@ -1287,7 +1287,7 @@ pg_GSS_recvauth(Port *port)
return ret;
}
#endif /* ENABLE_GSS */
#endif /* ENABLE_GSS */
/*----------------------------------------------------------------
@@ -1696,7 +1696,7 @@ pg_SSPI_make_upn(char *accountname,
pfree(upname);
return STATUS_OK;
}
#endif /* ENABLE_SSPI */
#endif /* ENABLE_SSPI */
@@ -1715,7 +1715,7 @@ static bool
interpret_ident_response(const char *ident_response,
char *ident_user)
{
const char *cursor = ident_response; /* Cursor into *ident_response */
const char *cursor = ident_response; /* Cursor into *ident_response */
/*
* Ident's response, in the telnet tradition, should end in crlf (\r\n).
@@ -1769,7 +1769,7 @@ interpret_ident_response(const char *ident_response,
{
int i; /* Index into *ident_user */
cursor++; /* Go over colon */
cursor++; /* Go over colon */
while (pg_isblank(*cursor))
cursor++; /* skip blanks */
/* Rest of line is user name. Copy it over. */
@@ -1805,7 +1805,7 @@ ident_inet(hbaPort *port)
const SockAddr remote_addr = port->raddr;
const SockAddr local_addr = port->laddr;
char ident_user[IDENT_USERNAME_MAX + 1];
pgsocket sock_fd = PGINVALID_SOCKET; /* for talking to Ident server */
pgsocket sock_fd = PGINVALID_SOCKET; /* for talking to Ident server */
int rc; /* Return code from a locally called function */
bool ident_return;
char remote_addr_s[NI_MAXHOST];
@@ -2010,7 +2010,7 @@ auth_peer(hbaPort *port)
return check_usermap(port->hba->usermap, port->user_name, ident_user, false);
}
#endif /* HAVE_UNIX_SOCKETS */
#endif /* HAVE_UNIX_SOCKETS */
/*----------------------------------------------------------------
@@ -2161,8 +2161,8 @@ CheckPAMAuth(Port *port, char *user, char *password)
* later used inside the PAM conversation to pass the password to the
* authentication module.
*/
pam_passw_conv.appdata_ptr = (char *) password; /* from password above,
* not allocated */
pam_passw_conv.appdata_ptr = (char *) password; /* from password above,
* not allocated */
/* Optionally, one can set the service name in pg_hba.conf */
if (port->hba->pamservice && port->hba->pamservice[0] != '\0')
@@ -2249,7 +2249,7 @@ CheckPAMAuth(Port *port, char *user, char *password)
return (retval == PAM_SUCCESS ? STATUS_OK : STATUS_ERROR);
}
#endif /* USE_PAM */
#endif /* USE_PAM */
/*----------------------------------------------------------------
@@ -2282,7 +2282,7 @@ CheckBSDAuth(Port *port, char *user)
return STATUS_OK;
}
#endif /* USE_BSD_AUTH */
#endif /* USE_BSD_AUTH */
/*----------------------------------------------------------------
@@ -2581,7 +2581,7 @@ CheckLDAPAuth(Port *port)
return STATUS_OK;
}
#endif /* USE_LDAP */
#endif /* USE_LDAP */
/*----------------------------------------------------------------
@@ -3071,8 +3071,8 @@ PerformRadiusTransaction(char *server, char *secret, char *portstr, char *identi
memcpy(cryptvector + 4, packet->vector, RADIUS_VECTOR_LENGTH); /* request
* authenticator, from
* original packet */
if (packetlength > RADIUS_HEADER_LENGTH) /* there may be no
* attributes at all */
if (packetlength > RADIUS_HEADER_LENGTH) /* there may be no
* attributes at all */
memcpy(cryptvector + RADIUS_HEADER_LENGTH, receive_buffer + RADIUS_HEADER_LENGTH, packetlength - RADIUS_HEADER_LENGTH);
memcpy(cryptvector + packetlength, secret, strlen(secret));

View File

@@ -796,7 +796,7 @@ lo_get_fragment_internal(Oid loOid, int64 offset, int32 nbytes)
if (loSize > offset)
{
if (nbytes >= 0 && nbytes <= loSize - offset)
result_length = nbytes; /* request is wholly inside LO */
result_length = nbytes; /* request is wholly inside LO */
else
result_length = loSize - offset; /* adjust to end of LO */
}

View File

@@ -664,7 +664,7 @@ ipv6eq(struct sockaddr_in6 *a, struct sockaddr_in6 *b)
return true;
}
#endif /* HAVE_IPV6 */
#endif /* HAVE_IPV6 */
/*
* Check whether host name matches pattern.
@@ -1022,7 +1022,7 @@ parse_hba_line(TokenizedLine *tok_line, int elevel)
*err_msg = "hostssl record cannot match because SSL is not supported by this build";
#endif
}
else if (token->string[4] == 'n') /* "hostnossl" */
else if (token->string[4] == 'n') /* "hostnossl" */
{
parsedline->conntype = ctHostNoSSL;
}
@@ -1726,7 +1726,7 @@ parse_hba_auth_opt(char *name, char *val, HbaLine *hbaline,
hbaline->ldapbasedn = pstrdup(urldata->lud_dn);
if (urldata->lud_attrs)
hbaline->ldapsearchattribute = pstrdup(urldata->lud_attrs[0]); /* only use first one */
hbaline->ldapsearchattribute = pstrdup(urldata->lud_attrs[0]); /* only use first one */
hbaline->ldapscope = urldata->lud_scope;
if (urldata->lud_filter)
{
@@ -1743,7 +1743,7 @@ parse_hba_auth_opt(char *name, char *val, HbaLine *hbaline,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("LDAP URLs not supported on this platform")));
*err_msg = "LDAP URLs not supported on this platform";
#endif /* not OpenLDAP */
#endif /* not OpenLDAP */
}
else if (strcmp(name, "ldaptls") == 0)
{

View File

@@ -99,7 +99,7 @@ range_sockaddr_AF_INET6(const struct sockaddr_in6 *addr,
return 1;
}
#endif /* HAVE_IPV6 */
#endif /* HAVE_IPV6 */
/*
* pg_sockaddr_cidr_mask - make a network mask of the appropriate family
@@ -471,7 +471,7 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data)
#define _SIZEOF_ADDR_IFREQ(ifr) \
sizeof (struct ifreq)
#endif
#endif /* !_SIZEOF_ADDR_IFREQ */
#endif /* !_SIZEOF_ADDR_IFREQ */
/*
* Enumerate the system's network interface addresses and call the callback
@@ -589,6 +589,6 @@ pg_foreach_ifaddr(PgIfAddrCallback callback, void *cb_data)
return 0;
}
#endif /* !defined(SIOCGIFCONF) */
#endif /* !defined(SIOCGIFCONF) */
#endif /* !HAVE_GETIFADDRS */
#endif /* !HAVE_GETIFADDRS */

View File

@@ -149,7 +149,7 @@ static int internal_flush(void);
#ifdef HAVE_UNIX_SOCKETS
static int Lock_AF_UNIX(char *unixSocketDir, char *unixSocketPath);
static int Setup_AF_UNIX(char *sock_path);
#endif /* HAVE_UNIX_SOCKETS */
#endif /* HAVE_UNIX_SOCKETS */
static PQcommMethods PqCommSocketMethods = {
socket_comm_reset,
@@ -253,7 +253,7 @@ socket_close(int code, Datum arg)
if (MyProcPort->gss->cred != GSS_C_NO_CREDENTIAL)
gss_release_cred(&min_s, &MyProcPort->gss->cred);
#endif /* ENABLE_GSS */
#endif /* ENABLE_GSS */
/*
* GSS and SSPI share the port->gss struct. Since nowhere else does a
@@ -261,7 +261,7 @@ socket_close(int code, Datum arg)
* BackendInitialize().
*/
free(MyProcPort->gss);
#endif /* ENABLE_GSS || ENABLE_SSPI */
#endif /* ENABLE_GSS || ENABLE_SSPI */
/*
* Cleanly shut down SSL layer. Nowhere else does a postmaster child
@@ -362,7 +362,7 @@ StreamServerPort(int family, char *hostName, unsigned short portNumber,
service = unixSocketPath;
}
else
#endif /* HAVE_UNIX_SOCKETS */
#endif /* HAVE_UNIX_SOCKETS */
{
snprintf(portNumberStr, sizeof(portNumberStr), "%d", portNumber);
service = portNumberStr;
@@ -680,7 +680,7 @@ Setup_AF_UNIX(char *sock_path)
}
return STATUS_OK;
}
#endif /* HAVE_UNIX_SOCKETS */
#endif /* HAVE_UNIX_SOCKETS */
/*
@@ -858,8 +858,8 @@ TouchSocketFiles(void)
#else /* !HAVE_UTIME */
#ifdef HAVE_UTIMES
utimes(sock_path, NULL);
#endif /* HAVE_UTIMES */
#endif /* HAVE_UTIME */
#endif /* HAVE_UTIMES */
#endif /* HAVE_UTIME */
}
}
@@ -1704,11 +1704,11 @@ pq_getkeepalivesidle(Port *port)
elog(LOG, "getsockopt(TCP_KEEPALIVE) failed: %m");
port->default_keepalives_idle = -1; /* don't know */
}
#endif /* TCP_KEEPIDLE */
#endif /* TCP_KEEPIDLE */
#else /* WIN32 */
/* We can't get the defaults on Windows, so return "don't know" */
port->default_keepalives_idle = -1;
#endif /* WIN32 */
#endif /* WIN32 */
}
return port->default_keepalives_idle;
@@ -1733,7 +1733,7 @@ pq_setkeepalivesidle(int idle, Port *port)
if (pq_getkeepalivesidle(port) < 0)
{
if (idle == 0)
return STATUS_OK; /* default is set but unknown */
return STATUS_OK; /* default is set but unknown */
else
return STATUS_ERROR;
}
@@ -1792,12 +1792,12 @@ pq_getkeepalivesinterval(Port *port)
&size) < 0)
{
elog(LOG, "getsockopt(TCP_KEEPINTVL) failed: %m");
port->default_keepalives_interval = -1; /* don't know */
port->default_keepalives_interval = -1; /* don't know */
}
#else
/* We can't get the defaults on Windows, so return "don't know" */
port->default_keepalives_interval = -1;
#endif /* WIN32 */
#endif /* WIN32 */
}
return port->default_keepalives_interval;
@@ -1822,7 +1822,7 @@ pq_setkeepalivesinterval(int interval, Port *port)
if (pq_getkeepalivesinterval(port) < 0)
{
if (interval == 0)
return STATUS_OK; /* default is set but unknown */
return STATUS_OK; /* default is set but unknown */
else
return STATUS_ERROR;
}
@@ -1872,7 +1872,7 @@ pq_getkeepalivescount(Port *port)
&size) < 0)
{
elog(LOG, "getsockopt(TCP_KEEPCNT) failed: %m");
port->default_keepalives_count = -1; /* don't know */
port->default_keepalives_count = -1; /* don't know */
}
}
@@ -1897,7 +1897,7 @@ pq_setkeepalivescount(int count, Port *port)
if (pq_getkeepalivescount(port) < 0)
{
if (count == 0)
return STATUS_OK; /* default is set but unknown */
return STATUS_OK; /* default is set but unknown */
else
return STATUS_ERROR;
}