0001-Fix-pgindent-s-postprocessing-of-multi-line-prototyp.patch
application/octet-stream
Filename: 0001-Fix-pgindent-s-postprocessing-of-multi-line-prototyp.patch
Type: application/octet-stream
Part: 0
Patch
Format: format-patch
Series: patch 0001
Subject: Fix pgindent's postprocessing of multi-line prototypes.
| File | + | − |
|---|---|---|
| src/tools/pgindent/pgindent | 19 | 0 |
From eaf73c7a06ed889f79a9e8dd3ea7e6e01c23a5b7 Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@gmail.com>
Date: Sun, 7 Apr 2019 00:00:27 +1300
Subject: [PATCH] Fix pgindent's postprocessing of multi-line prototypes.
---
src/tools/pgindent/pgindent | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent
index 2d81672e15..0220fcdd72 100755
--- a/src/tools/pgindent/pgindent
+++ b/src/tools/pgindent/pgindent
@@ -266,6 +266,25 @@ sub post_indent
)
!$1 . (substr($1,-1,1) eq '*' ? '' : ' ') . $2!gmxe;
+ # Fix the formatting of multi-line arguments in prototypes that were
+ # mangled by the above.
+ my @lines = split /\n/, $source;
+ my $level;
+ $source = "";
+ foreach my $line (@lines) {
+ if ($line =~ /^([a-zA-Z][^(]*\().*,$/) {
+ $level = length($1);
+ print "got level = $level, line = $line\n";
+ $source = $source . $line . "\n";
+ } elsif ($level && $line =~ /^\s+(.*)$/) {
+ $line = "\t" x ($level / 4) . " " x ($level % 4) . $1;
+ $source = $source . $line . "\n";
+ } else {
+ $level = undef;
+ $source = $source . $line . "\n";
+ }
+ }
+
return $source;
}
--
2.21.0