1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-20 05:03:10 +03:00

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
This commit is contained in:
Tom Lane
2023-04-08 11:48:36 -04:00
parent bbec50de16
commit 064750af4f
3 changed files with 8 additions and 7 deletions

View File

@ -51,7 +51,7 @@ static char sccsid[] = "@(#)args.c 8.1 (Berkeley) 6/6/93";
#include "indent_globs.h" #include "indent_globs.h"
#include "indent.h" #include "indent.h"
#define INDENT_VERSION "2.1.1" #define INDENT_VERSION "2.1.2"
/* profile types */ /* profile types */
#define PRO_SPECIAL 1 /* special case */ #define PRO_SPECIAL 1 /* special case */

View File

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

View File

@ -13,7 +13,7 @@ use IO::Handle;
use Getopt::Long; use Getopt::Long;
# Update for pg_bsd_indent version # Update for pg_bsd_indent version
my $INDENT_VERSION = "2.1.1"; my $INDENT_VERSION = "2.1.2";
# Our standard indent settings # Our standard indent settings
my $indent_opts = my $indent_opts =