Skip to content

Commit c7b8998

Browse files
committed
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 e3860ff 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/[email protected] Discussion: https://postgr.es/m/[email protected]
1 parent f669c09 commit c7b8998

File tree

1,107 files changed

+3435
-3516
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,107 files changed

+3435
-3516
lines changed

contrib/bloom/bloom.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ typedef BloomPageOpaqueData *BloomPageOpaque;
7575

7676
/* Preserved page numbers */
7777
#define BLOOM_METAPAGE_BLKNO (0)
78-
#define BLOOM_HEAD_BLKNO (1) /* first data page */
78+
#define BLOOM_HEAD_BLKNO (1) /* first data page */
7979

8080
/*
8181
* We store Bloom signatures as arrays of uint16 words.
@@ -101,8 +101,8 @@ typedef struct BloomOptions
101101
{
102102
int32 vl_len_; /* varlena header (do not touch directly!) */
103103
int bloomLength; /* length of signature in words (not bits!) */
104-
int bitSize[INDEX_MAX_KEYS]; /* # of bits generated for
105-
* each index key */
104+
int bitSize[INDEX_MAX_KEYS]; /* # of bits generated for each
105+
* index key */
106106
} BloomOptions;
107107

108108
/*

contrib/btree_gist/btree_utils_num.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ typedef struct
4242

4343
/* Methods */
4444

45-
bool (*f_gt) (const void *, const void *, FmgrInfo *); /* greater than */
46-
bool (*f_ge) (const void *, const void *, FmgrInfo *); /* greater or equal */
47-
bool (*f_eq) (const void *, const void *, FmgrInfo *); /* equal */
48-
bool (*f_le) (const void *, const void *, FmgrInfo *); /* less or equal */
49-
bool (*f_lt) (const void *, const void *, FmgrInfo *); /* less than */
50-
int (*f_cmp) (const void *, const void *, FmgrInfo *); /* key compare function */
51-
float8 (*f_dist) (const void *, const void *, FmgrInfo *); /* key distance function */
45+
bool (*f_gt) (const void *, const void *, FmgrInfo *); /* greater than */
46+
bool (*f_ge) (const void *, const void *, FmgrInfo *); /* greater or equal */
47+
bool (*f_eq) (const void *, const void *, FmgrInfo *); /* equal */
48+
bool (*f_le) (const void *, const void *, FmgrInfo *); /* less or equal */
49+
bool (*f_lt) (const void *, const void *, FmgrInfo *); /* less than */
50+
int (*f_cmp) (const void *, const void *, FmgrInfo *); /* key compare function */
51+
float8 (*f_dist) (const void *, const void *, FmgrInfo *); /* key distance function */
5252
} gbtree_ninfo;
5353

5454

contrib/btree_gist/btree_utils_var.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v,
488488

489489
cur = (char *) DatumGetPointer(entryvec->vector[i].key);
490490
ro = gbt_var_key_readable((GBT_VARKEY *) cur);
491-
if (ro.lower == ro.upper) /* leaf */
491+
if (ro.lower == ro.upper) /* leaf */
492492
{
493493
sv[svcntr] = gbt_var_leaf2node((GBT_VARKEY *) cur, tinfo, flinfo);
494494
arr[i].t = sv[svcntr];

contrib/btree_gist/btree_utils_var.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ typedef struct
4040
bool (*f_le) (const void *, const void *, Oid, FmgrInfo *); /* less equal */
4141
bool (*f_lt) (const void *, const void *, Oid, FmgrInfo *); /* less than */
4242
int32 (*f_cmp) (const void *, const void *, Oid, FmgrInfo *); /* compare */
43-
GBT_VARKEY *(*f_l2n) (GBT_VARKEY *, FmgrInfo *flinfo); /* convert leaf to node */
43+
GBT_VARKEY *(*f_l2n) (GBT_VARKEY *, FmgrInfo *flinfo); /* convert leaf to node */
4444
} gbtree_vinfo;
4545

4646

contrib/btree_gist/btree_uuid.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static double
171171
uuid_2_double(const pg_uuid_t *u)
172172
{
173173
uint64 uu[2];
174-
const double two64 = 18446744073709551616.0; /* 2^64 */
174+
const double two64 = 18446744073709551616.0; /* 2^64 */
175175

176176
/* Source data may not be suitably aligned, so copy */
177177
memcpy(uu, u->data, UUID_LEN);

contrib/cube/cubedata.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ typedef struct NDBOX
5454
#define PG_RETURN_NDBOX(x) PG_RETURN_POINTER(x)
5555

5656
/* GiST operator strategy numbers */
57-
#define CubeKNNDistanceCoord 15 /* ~> */
58-
#define CubeKNNDistanceTaxicab 16 /* <#> */
59-
#define CubeKNNDistanceEuclid 17 /* <-> */
60-
#define CubeKNNDistanceChebyshev 18 /* <=> */
57+
#define CubeKNNDistanceCoord 15 /* ~> */
58+
#define CubeKNNDistanceTaxicab 16 /* <#> */
59+
#define CubeKNNDistanceEuclid 17 /* <-> */
60+
#define CubeKNNDistanceChebyshev 18 /* <=> */
6161

6262
/* in cubescan.l */
6363
extern int cube_yylex(void);

contrib/dblink/dblink.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ typedef struct remoteConn
6767
{
6868
PGconn *conn; /* Hold the remote connection */
6969
int openCursorCount; /* The number of open cursors */
70-
bool newXactForCursor; /* Opened a transaction for a cursor */
70+
bool newXactForCursor; /* Opened a transaction for a cursor */
7171
} remoteConn;
7272

7373
typedef struct storeInfo
@@ -1098,7 +1098,7 @@ storeQueryResult(volatile storeInfo *sinfo, PGconn *conn, const char *sql)
10981098
if (!PQsendQuery(conn, sql))
10991099
elog(ERROR, "could not send query: %s", pchomp(PQerrorMessage(conn)));
11001100

1101-
if (!PQsetSingleRowMode(conn)) /* shouldn't fail */
1101+
if (!PQsetSingleRowMode(conn)) /* shouldn't fail */
11021102
elog(ERROR, "failed to set single-row mode for dblink query");
11031103

11041104
for (;;)

contrib/file_fdw/file_fdw.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -544,13 +544,13 @@ fileGetForeignPaths(PlannerInfo *root,
544544
*/
545545
add_path(baserel, (Path *)
546546
create_foreignscan_path(root, baserel,
547-
NULL, /* default pathtarget */
547+
NULL, /* default pathtarget */
548548
baserel->rows,
549549
startup_cost,
550550
total_cost,
551-
NIL, /* no pathkeys */
552-
NULL, /* no outer rel either */
553-
NULL, /* no extra plan */
551+
NIL, /* no pathkeys */
552+
NULL, /* no outer rel either */
553+
NULL, /* no extra plan */
554554
coptions));
555555

556556
/*

contrib/fuzzystrmatch/dmetaphone.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ The remaining code is authored by Andrew Dunstan <[email protected]> and
111111
#include <string.h>
112112
#include <stdarg.h>
113113

114-
#endif /* DMETAPHONE_MAIN */
114+
#endif /* DMETAPHONE_MAIN */
115115

116116
#include <assert.h>
117117
#include <ctype.h>
@@ -197,7 +197,7 @@ dmetaphone_alt(PG_FUNCTION_ARGS)
197197
* in a case like this.
198198
*/
199199

200-
#define META_FREE(x) ((void)true) /* pfree((x)) */
200+
#define META_FREE(x) ((void)true) /* pfree((x)) */
201201
#else /* not defined DMETAPHONE_MAIN */
202202

203203
/* use the standard malloc library when not running in PostgreSQL */
@@ -209,7 +209,7 @@ dmetaphone_alt(PG_FUNCTION_ARGS)
209209
(v = (t*)realloc((v),((n)*sizeof(t))))
210210

211211
#define META_FREE(x) free((x))
212-
#endif /* defined DMETAPHONE_MAIN */
212+
#endif /* defined DMETAPHONE_MAIN */
213213

214214

215215

@@ -977,7 +977,7 @@ DoubleMetaphone(char *str, char **codes)
977977
}
978978
}
979979

980-
if (GetAt(original, current + 1) == 'J') /* it could happen! */
980+
if (GetAt(original, current + 1) == 'J') /* it could happen! */
981981
current += 2;
982982
else
983983
current += 1;

contrib/hstore/hstore.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ extern Pairs *hstoreArrayToPairs(ArrayType *a, int *npairs);
181181
#define HStoreExistsStrategyNumber 9
182182
#define HStoreExistsAnyStrategyNumber 10
183183
#define HStoreExistsAllStrategyNumber 11
184-
#define HStoreOldContainsStrategyNumber 13 /* backwards compatibility */
184+
#define HStoreOldContainsStrategyNumber 13 /* backwards compatibility */
185185

186186
/*
187187
* defining HSTORE_POLLUTE_NAMESPACE=0 will prevent use of old function names;
@@ -202,4 +202,4 @@ extern Pairs *hstoreArrayToPairs(ArrayType *a, int *npairs);
202202
extern int no_such_variable
203203
#endif
204204

205-
#endif /* __HSTORE_H__ */
205+
#endif /* __HSTORE_H__ */

contrib/hstore/hstore_io.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ hstore_from_record(PG_FUNCTION_ARGS)
829829
my_extra->ncolumns = ncolumns;
830830
}
831831

832-
Assert(ncolumns <= MaxTupleAttributeNumber); /* thus, no overflow */
832+
Assert(ncolumns <= MaxTupleAttributeNumber); /* thus, no overflow */
833833
pairs = palloc(ncolumns * sizeof(Pairs));
834834

835835
if (rec)

contrib/intarray/_int.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,4 @@ int compDESC(const void *a, const void *b);
173173
(direction) ? compASC : compDESC ); \
174174
} while(0)
175175

176-
#endif /* ___INT_H__ */
176+
#endif /* ___INT_H__ */

contrib/intarray/_int_tool.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ internal_size(int *a, int len)
282282

283283
for (i = 0; i < len; i += 2)
284284
{
285-
if (!i || a[i] != a[i - 1]) /* do not count repeated range */
285+
if (!i || a[i] != a[i - 1]) /* do not count repeated range */
286286
size += a[i + 1] - a[i] + 1;
287287
}
288288

contrib/isn/isn.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ check_table(const char *(*TABLE)[2], const unsigned TABLE_index[10][2])
131131
elog(DEBUG1, "index %d is invalid", j);
132132
return false;
133133
}
134-
#endif /* ISN_DEBUG */
134+
#endif /* ISN_DEBUG */
135135

136136
/*----------------------------------------------------------
137137
* Formatting and conversion routines.
@@ -699,11 +699,11 @@ string2ean(const char *str, bool errorOK, ean13 *result,
699699
/* recognize and validate the number: */
700700
while (*aux2 && length <= 13)
701701
{
702-
last = (*(aux2 + 1) == '!' || *(aux2 + 1) == '\0'); /* is the last character */
702+
last = (*(aux2 + 1) == '!' || *(aux2 + 1) == '\0'); /* is the last character */
703703
digit = (isdigit((unsigned char) *aux2) != 0); /* is current character
704704
* a digit? */
705-
if (*aux2 == '?' && last) /* automagically calculate check digit
706-
* if it's '?' */
705+
if (*aux2 == '?' && last) /* automagically calculate check digit if
706+
* it's '?' */
707707
magic = digit = true;
708708
if (length == 0 && (*aux2 == 'M' || *aux2 == 'm'))
709709
{
@@ -832,8 +832,8 @@ string2ean(const char *str, bool errorOK, ean13 *result,
832832
goto eanwrongtype;
833833
break;
834834
case ISMN:
835-
memcpy(buf, "9790", 4); /* this isn't for sure yet, for now
836-
* ISMN it's only 9790 */
835+
memcpy(buf, "9790", 4); /* this isn't for sure yet, for now ISMN
836+
* it's only 9790 */
837837
valid = (valid && ((rcheck = checkdig(buf, 13)) == check || magic));
838838
break;
839839
case ISBN:
@@ -1123,7 +1123,7 @@ accept_weak_input(PG_FUNCTION_ARGS)
11231123
g_weak = PG_GETARG_BOOL(0);
11241124
#else
11251125
/* function has no effect */
1126-
#endif /* ISN_WEAK_MODE */
1126+
#endif /* ISN_WEAK_MODE */
11271127
PG_RETURN_BOOL(g_weak);
11281128
}
11291129

contrib/isn/isn.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ typedef uint64 ean13;
3232

3333
extern void initialize(void);
3434

35-
#endif /* ISN_H */
35+
#endif /* ISN_H */

contrib/lo/lo.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ lo_manage(PG_FUNCTION_ARGS)
3232
HeapTuple newtuple; /* The new value for tuple */
3333
HeapTuple trigtuple; /* The original value of tuple */
3434

35-
if (!CALLED_AS_TRIGGER(fcinfo)) /* internal error */
35+
if (!CALLED_AS_TRIGGER(fcinfo)) /* internal error */
3636
elog(ERROR, "%s: not fired by trigger manager",
3737
trigdata->tg_trigger->tgname);
3838

39-
if (!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event)) /* internal error */
39+
if (!TRIGGER_FIRED_FOR_ROW(trigdata->tg_event)) /* internal error */
4040
elog(ERROR, "%s: must be fired for row",
4141
trigdata->tg_trigger->tgname);
4242

contrib/ltree/ltree.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ typedef struct
125125
#define OPR 3
126126
#define OPEN 4
127127
#define CLOSE 5
128-
#define VALTRUE 6 /* for stop words */
128+
#define VALTRUE 6 /* for stop words */
129129
#define VALFALSE 7
130130

131131

contrib/ltree/ltree_gist.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ ltree_picksplit(PG_FUNCTION_ARGS)
302302
for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
303303
{
304304
array[j].index = j;
305-
lu = GETENTRY(entryvec, j); /* use as tmp val */
305+
lu = GETENTRY(entryvec, j); /* use as tmp val */
306306
array[j].r = LTG_GETLNODE(lu);
307307
}
308308

@@ -312,7 +312,7 @@ ltree_picksplit(PG_FUNCTION_ARGS)
312312
lu_l = lu_r = ru_l = ru_r = NULL;
313313
for (j = FirstOffsetNumber; j <= maxoff; j = OffsetNumberNext(j))
314314
{
315-
lu = GETENTRY(entryvec, array[j].index); /* use as tmp val */
315+
lu = GETENTRY(entryvec, array[j].index); /* use as tmp val */
316316
if (j <= (maxoff - FirstOffsetNumber + 1) / 2)
317317
{
318318
v->spl_left[v->spl_nleft] = array[j].index;

contrib/pageinspect/pageinspect.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
/* in rawpage.c */
1919
extern Page get_page_from_raw(bytea *raw_page);
2020

21-
#endif /* _PAGEINSPECT_H_ */
21+
#endif /* _PAGEINSPECT_H_ */

contrib/pg_buffercache/pg_buffercache_pages.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pg_buffercache_pages(PG_FUNCTION_ARGS)
6666
FuncCallContext *funcctx;
6767
Datum result;
6868
MemoryContext oldcontext;
69-
BufferCachePagesContext *fctx; /* User function context. */
69+
BufferCachePagesContext *fctx; /* User function context. */
7070
TupleDesc tupledesc;
7171
TupleDesc expected_tupledesc;
7272
HeapTuple tuple;

contrib/pg_standby/pg_standby.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ int maxwaittime = 0; /* how long are we prepared to wait for? */
4444
int keepfiles = 0; /* number of WAL files to keep, 0 keep all */
4545
int maxretries = 3; /* number of retries on restore command */
4646
bool debug = false; /* are we debugging? */
47-
bool need_cleanup = false; /* do we need to remove files from
48-
* archive? */
47+
bool need_cleanup = false; /* do we need to remove files from
48+
* archive? */
4949

5050
#ifndef WIN32
5151
static volatile sig_atomic_t signaled = false;
@@ -59,8 +59,8 @@ char *restartWALFileName; /* the file from which we can restart restore */
5959
char *priorWALFileName; /* the file we need to get from archive */
6060
char WALFilePath[MAXPGPATH * 2]; /* the file path including archive */
6161
char restoreCommand[MAXPGPATH]; /* run this to restore */
62-
char exclusiveCleanupFileName[MAXFNAMELEN]; /* the file we need to
63-
* get from archive */
62+
char exclusiveCleanupFileName[MAXFNAMELEN]; /* the file we need to get
63+
* from archive */
6464

6565
/*
6666
* Two types of failover are supported (smart and fast failover).
@@ -582,7 +582,7 @@ main(int argc, char **argv)
582582
* There's no way to trigger failover via signal on Windows.
583583
*/
584584
(void) pqsignal(SIGUSR1, sighandler);
585-
(void) pqsignal(SIGINT, sighandler); /* deprecated, use SIGUSR1 */
585+
(void) pqsignal(SIGINT, sighandler); /* deprecated, use SIGUSR1 */
586586
(void) pqsignal(SIGQUIT, sigquit_handler);
587587
#endif
588588

0 commit comments

Comments
 (0)