summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2023-04-08 15:48:36 +0000
committerTom Lane2023-04-08 15:48:45 +0000
commit064750af4f4ebab9c0d47d502c7ff7e3c9533f9f (patch)
treea35b3eb3c8ac0db0ac10f2a771143e72a510743e
parentbbec50de16d2bf6e1a2878ff0f7e39dbd86ecff8 (diff)
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/[email protected]
-rw-r--r--src/tools/pg_bsd_indent/args.c2
-rw-r--r--src/tools/pg_bsd_indent/io.c11
-rwxr-xr-xsrc/tools/pgindent/pgindent2
3 files changed, 8 insertions, 7 deletions
diff --git a/src/tools/pg_bsd_indent/args.c b/src/tools/pg_bsd_indent/args.c
index d08b086a88..38eaa5a5bf 100644
--- a/src/tools/pg_bsd_indent/args.c
+++ b/src/tools/pg_bsd_indent/args.c
@@ -51,7 +51,7 @@ static char sccsid[] = "@(#)args.c 8.1 (Berkeley) 6/6/93";
#include "indent_globs.h"
#include "indent.h"
-#define INDENT_VERSION "2.1.1"
+#define INDENT_VERSION "2.1.2"
/* profile types */
#define PRO_SPECIAL 1 /* special case */
diff --git a/src/tools/pg_bsd_indent/io.c b/src/tools/pg_bsd_indent/io.c
index 4149424294..9d64ca1ee5 100644
--- a/src/tools/pg_bsd_indent/io.c
+++ b/src/tools/pg_bsd_indent/io.c
@@ -201,11 +201,12 @@ dump_line(void)
ps.decl_on_line = ps.in_decl; /* if we are in the middle of a
* declaration, remember that fact for
* proper comment indentation */
- ps.ind_stmt = ps.in_stmt & ~ps.in_decl; /* next line should be
- * indented if we have not
- * completed this stmt and if
- * we are not in the middle of
- * a declaration */
+ /* next line should be indented if we have not completed this stmt, and
+ * either we are not in a declaration or we are in an initialization
+ * assignment; but not if we're within braces in an initialization,
+ * because that scenario is handled by other rules. */
+ ps.ind_stmt = ps.in_stmt &&
+ (!ps.in_decl || (ps.block_init && ps.block_init_level <= 0));
ps.use_ff = false;
ps.dumped_decl_indent = 0;
*(e_lab = s_lab) = '\0'; /* reset buffers */
diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent
index 3c48f3c46b..58692d073b 100755
--- a/src/tools/pgindent/pgindent
+++ b/src/tools/pgindent/pgindent
@@ -13,7 +13,7 @@ use IO::Handle;
use Getopt::Long;
# Update for pg_bsd_indent version
-my $INDENT_VERSION = "2.1.1";
+my $INDENT_VERSION = "2.1.2";
# Our standard indent settings
my $indent_opts =