1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-14 08:21:07 +03:00

Initial pgindent run with pg_bsd_indent version 2.0.

The new indent version includes numerous fixes thanks to Piotr Stefaniak.
The main changes visible in this commit are:

* Nicer formatting of function-pointer declarations.
* No longer unexpectedly removes spaces in expressions using casts,
  sizeof, or offsetof.
* No longer wants to add a space in "struct structname *varname", as
  well as some similar cases for const- or volatile-qualified pointers.
* Declarations using PG_USED_FOR_ASSERTS_ONLY are formatted more nicely.
* Fixes bug where comments following declarations were sometimes placed
  with no space separating them from the code.
* Fixes some odd decisions for comments following case labels.
* Fixes some cases where comments following code were indented to less
  than the expected column 33.

On the less good side, it now tends to put more whitespace around typedef
names that are not listed in typedefs.list.  This might encourage us to
put more effort into typedef name collection; it's not really a bug in
indent itself.

There are more changes coming after this round, having to do with comment
indentation and alignment of lines appearing within parentheses.  I wanted
to limit the size of the diffs to something that could be reviewed without
one's eyes completely glazing over, so it seemed better to split up the
changes as much as practical.

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 14:39:04 -04:00
parent 8ff6d4ec78
commit e3860ffa4d
379 changed files with 1725 additions and 1707 deletions

View File

@ -34,22 +34,22 @@
static int DecodeNumber(int flen, char *field, bool haveTextMonth,
int fmask, int *tmask,
struct pg_tm * tm, fsec_t *fsec, bool *is2digits);
struct pg_tm *tm, fsec_t *fsec, bool *is2digits);
static int DecodeNumberField(int len, char *str,
int fmask, int *tmask,
struct pg_tm * tm, fsec_t *fsec, bool *is2digits);
struct pg_tm *tm, fsec_t *fsec, bool *is2digits);
static int DecodeTime(char *str, int fmask, int range,
int *tmask, struct pg_tm * tm, fsec_t *fsec);
int *tmask, struct pg_tm *tm, fsec_t *fsec);
static const datetkn *datebsearch(const char *key, const datetkn *base, int nel);
static int DecodeDate(char *str, int fmask, int *tmask, bool *is2digits,
struct pg_tm * tm);
struct pg_tm *tm);
static char *AppendSeconds(char *cp, int sec, fsec_t fsec,
int precision, bool fillzeros);
static void AdjustFractSeconds(double frac, struct pg_tm * tm, fsec_t *fsec,
static void AdjustFractSeconds(double frac, struct pg_tm *tm, fsec_t *fsec,
int scale);
static void AdjustFractDays(double frac, struct pg_tm * tm, fsec_t *fsec,
static void AdjustFractDays(double frac, struct pg_tm *tm, fsec_t *fsec,
int scale);
static int DetermineTimeZoneOffsetInternal(struct pg_tm * tm, pg_tz *tzp,
static int DetermineTimeZoneOffsetInternal(struct pg_tm *tm, pg_tz *tzp,
pg_time_t *tp);
static bool DetermineTimeZoneAbbrevOffsetInternal(pg_time_t t,
const char *abbr, pg_tz *tzp,
@ -311,7 +311,7 @@ date2j(int y, int m, int d)
julian += 7834 * m / 256 + d;
return julian;
} /* date2j() */
} /* date2j() */
void
j2date(int jd, int *year, int *month, int *day)
@ -338,7 +338,7 @@ j2date(int jd, int *year, int *month, int *day)
*month = (quad + 10) % MONTHS_PER_YEAR + 1;
return;
} /* j2date() */
} /* j2date() */
/*
@ -358,7 +358,7 @@ j2day(int date)
date += 7;
return date;
} /* j2day() */
} /* j2day() */
/*
@ -367,7 +367,7 @@ j2day(int date)
* Get the transaction start time ("now()") broken down as a struct pg_tm.
*/
void
GetCurrentDateTime(struct pg_tm * tm)
GetCurrentDateTime(struct pg_tm *tm)
{
int tz;
fsec_t fsec;
@ -384,7 +384,7 @@ GetCurrentDateTime(struct pg_tm * tm)
* including fractional seconds and timezone offset.
*/
void
GetCurrentTimeUsec(struct pg_tm * tm, fsec_t *fsec, int *tzp)
GetCurrentTimeUsec(struct pg_tm *tm, fsec_t *fsec, int *tzp)
{
int tz;
@ -471,7 +471,7 @@ AppendSeconds(char *cp, int sec, fsec_t fsec, int precision, bool fillzeros)
* there; callers are responsible for NUL terminating str themselves.
*/
static char *
AppendTimestampSeconds(char *cp, struct pg_tm * tm, fsec_t fsec)
AppendTimestampSeconds(char *cp, struct pg_tm *tm, fsec_t fsec)
{
return AppendSeconds(cp, tm->tm_sec, fsec, MAX_TIMESTAMP_PRECISION, true);
}
@ -481,7 +481,7 @@ AppendTimestampSeconds(char *cp, struct pg_tm * tm, fsec_t fsec)
* We assume the input frac is less than 1 so overflow is not an issue.
*/
static void
AdjustFractSeconds(double frac, struct pg_tm * tm, fsec_t *fsec, int scale)
AdjustFractSeconds(double frac, struct pg_tm *tm, fsec_t *fsec, int scale)
{
int sec;
@ -496,7 +496,7 @@ AdjustFractSeconds(double frac, struct pg_tm * tm, fsec_t *fsec, int scale)
/* As above, but initial scale produces days */
static void
AdjustFractDays(double frac, struct pg_tm * tm, fsec_t *fsec, int scale)
AdjustFractDays(double frac, struct pg_tm *tm, fsec_t *fsec, int scale)
{
int extra_days;
@ -781,7 +781,7 @@ ParseDateTime(const char *timestr, char *workbuf, size_t buflen,
*/
int
DecodeDateTime(char **field, int *ftype, int nf,
int *dtype, struct pg_tm * tm, fsec_t *fsec, int *tzp)
int *dtype, struct pg_tm *tm, fsec_t *fsec, int *tzp)
{
int fmask = 0,
tmask,
@ -1468,7 +1468,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
* though probably some higher-level code will.
*/
int
DetermineTimeZoneOffset(struct pg_tm * tm, pg_tz *tzp)
DetermineTimeZoneOffset(struct pg_tm *tm, pg_tz *tzp)
{
pg_time_t t;
@ -1490,7 +1490,7 @@ DetermineTimeZoneOffset(struct pg_tm * tm, pg_tz *tzp)
* of mktime(), anyway.
*/
static int
DetermineTimeZoneOffsetInternal(struct pg_tm * tm, pg_tz *tzp, pg_time_t *tp)
DetermineTimeZoneOffsetInternal(struct pg_tm *tm, pg_tz *tzp, pg_time_t *tp)
{
int date,
sec;
@ -1626,7 +1626,7 @@ overflow:
* back to doing DetermineTimeZoneOffset().)
*/
int
DetermineTimeZoneAbbrevOffset(struct pg_tm * tm, const char *abbr, pg_tz *tzp)
DetermineTimeZoneAbbrevOffset(struct pg_tm *tm, const char *abbr, pg_tz *tzp)
{
pg_time_t t;
int zone_offset;
@ -1742,7 +1742,7 @@ DetermineTimeZoneAbbrevOffsetInternal(pg_time_t t, const char *abbr, pg_tz *tzp,
*/
int
DecodeTimeOnly(char **field, int *ftype, int nf,
int *dtype, struct pg_tm * tm, fsec_t *fsec, int *tzp)
int *dtype, struct pg_tm *tm, fsec_t *fsec, int *tzp)
{
int fmask = 0,
tmask,
@ -2367,7 +2367,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
*/
static int
DecodeDate(char *str, int fmask, int *tmask, bool *is2digits,
struct pg_tm * tm)
struct pg_tm *tm)
{
fsec_t fsec;
int nf = 0;
@ -2477,7 +2477,7 @@ DecodeDate(char *str, int fmask, int *tmask, bool *is2digits,
*/
int
ValidateDate(int fmask, bool isjulian, bool is2digits, bool bc,
struct pg_tm * tm)
struct pg_tm *tm)
{
if (fmask & DTK_M(YEAR))
{
@ -2556,7 +2556,7 @@ ValidateDate(int fmask, bool isjulian, bool is2digits, bool bc,
*/
static int
DecodeTime(char *str, int fmask, int range,
int *tmask, struct pg_tm * tm, fsec_t *fsec)
int *tmask, struct pg_tm *tm, fsec_t *fsec)
{
char *cp;
int dterr;
@ -2632,7 +2632,7 @@ DecodeTime(char *str, int fmask, int range,
*/
static int
DecodeNumber(int flen, char *str, bool haveTextMonth, int fmask,
int *tmask, struct pg_tm * tm, fsec_t *fsec, bool *is2digits)
int *tmask, struct pg_tm *tm, fsec_t *fsec, bool *is2digits)
{
int val;
char *cp;
@ -2817,7 +2817,7 @@ DecodeNumber(int flen, char *str, bool haveTextMonth, int fmask,
*/
static int
DecodeNumberField(int len, char *str, int fmask,
int *tmask, struct pg_tm * tm, fsec_t *fsec, bool *is2digits)
int *tmask, struct pg_tm *tm, fsec_t *fsec, bool *is2digits)
{
char *cp;
@ -3068,7 +3068,7 @@ DecodeSpecial(int field, char *lowtoken, int *val)
* Zero out a pg_tm and associated fsec_t
*/
static inline void
ClearPgTm(struct pg_tm * tm, fsec_t *fsec)
ClearPgTm(struct pg_tm *tm, fsec_t *fsec)
{
tm->tm_year = 0;
tm->tm_mon = 0;
@ -3093,7 +3093,7 @@ ClearPgTm(struct pg_tm * tm, fsec_t *fsec)
*/
int
DecodeInterval(char **field, int *ftype, int nf, int range,
int *dtype, struct pg_tm * tm, fsec_t *fsec)
int *dtype, struct pg_tm *tm, fsec_t *fsec)
{
bool is_before = FALSE;
char *cp;
@ -3519,7 +3519,7 @@ ISO8601IntegerWidth(char *fieldstart)
*/
int
DecodeISO8601Interval(char *str,
int *dtype, struct pg_tm * tm, fsec_t *fsec)
int *dtype, struct pg_tm *tm, fsec_t *fsec)
{
bool datepart = true;
bool havefield = false;
@ -3749,7 +3749,7 @@ DecodeUnits(int field, char *lowtoken, int *val)
}
return type;
} /* DecodeUnits() */
} /* DecodeUnits() */
/*
* Report an error detected by one of the datetime input processing routines.
@ -3881,7 +3881,7 @@ EncodeTimezone(char *str, int tz, int style)
* Encode date as local time.
*/
void
EncodeDateOnly(struct pg_tm * tm, int style, char *str)
EncodeDateOnly(struct pg_tm *tm, int style, char *str)
{
Assert(tm->tm_mon >= 1 && tm->tm_mon <= MONTHS_PER_YEAR);
@ -3966,7 +3966,7 @@ EncodeDateOnly(struct pg_tm * tm, int style, char *str)
* output.
*/
void
EncodeTimeOnly(struct pg_tm * tm, fsec_t fsec, bool print_tz, int tz, int style, char *str)
EncodeTimeOnly(struct pg_tm *tm, fsec_t fsec, bool print_tz, int tz, int style, char *str)
{
str = pg_ltostr_zeropad(str, tm->tm_hour, 2);
*str++ = ':';
@ -3996,7 +3996,7 @@ EncodeTimeOnly(struct pg_tm * tm, fsec_t fsec, bool print_tz, int tz, int style,
* XSD - yyyy-mm-ddThh:mm:ss.ss+/-tz
*/
void
EncodeDateTime(struct pg_tm * tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str)
EncodeDateTime(struct pg_tm *tm, fsec_t fsec, bool print_tz, int tz, const char *tzn, int style, char *str)
{
int day;
@ -4238,7 +4238,7 @@ AddVerboseIntPart(char *cp, int value, const char *units,
* "day-time literal"s (that look like ('4 5:6:7')
*/
void
EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str)
EncodeInterval(struct pg_tm *tm, fsec_t fsec, int style, char *str)
{
char *cp = str;
int year = tm->tm_year;