Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 064750a

Browse files
committed
Improve indentation of multiline initialization expressions.
If a variable has an initialization expression that wraps onto the next line(s), pg_bsd_indent will now indent the continuation lines one stop, instead of aligning them flush with the variable declaration. We've been holding off applying this until the last v16 CF finished, but now it's time. Thomas Munro and Tom Lane Discussion: https://postgr.es/m/20230120013137.7ky7nl4e4zjorrfa@awork3.anarazel.de
1 parent bbec50d commit 064750a

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/tools/pg_bsd_indent/args.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static char sccsid[] = "@(#)args.c 8.1 (Berkeley) 6/6/93";
5151
#include "indent_globs.h"
5252
#include "indent.h"
5353

54-
#define INDENT_VERSION "2.1.1"
54+
#define INDENT_VERSION "2.1.2"
5555

5656
/* profile types */
5757
#define PRO_SPECIAL 1 /* special case */

src/tools/pg_bsd_indent/io.c

+6-5
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,12 @@ dump_line(void)
201201
ps.decl_on_line = ps.in_decl; /* if we are in the middle of a
202202
* declaration, remember that fact for
203203
* proper comment indentation */
204-
ps.ind_stmt = ps.in_stmt & ~ps.in_decl; /* next line should be
205-
* indented if we have not
206-
* completed this stmt and if
207-
* we are not in the middle of
208-
* a declaration */
204+
/* next line should be indented if we have not completed this stmt, and
205+
* either we are not in a declaration or we are in an initialization
206+
* assignment; but not if we're within braces in an initialization,
207+
* because that scenario is handled by other rules. */
208+
ps.ind_stmt = ps.in_stmt &&
209+
(!ps.in_decl || (ps.block_init && ps.block_init_level <= 0));
209210
ps.use_ff = false;
210211
ps.dumped_decl_indent = 0;
211212
*(e_lab = s_lab) = '\0'; /* reset buffers */

src/tools/pgindent/pgindent

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use IO::Handle;
1313
use Getopt::Long;
1414

1515
# Update for pg_bsd_indent version
16-
my $INDENT_VERSION = "2.1.1";
16+
my $INDENT_VERSION = "2.1.2";
1717

1818
# Our standard indent settings
1919
my $indent_opts =

0 commit comments

Comments
 (0)