[libvirt] [PATCH 21/22] build-aux:check-spacing: Add indicator to help correcting misaligned stuff

Shi Lei shi_lei at massclouds.com
Fri Oct 5 08:11:44 UTC 2018


This patch definitely indicates the correct position for misaligned
stuff.

Signed-off-by: Shi Lei <shi_lei at massclouds.com>
---
 build-aux/check-spacing.pl | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/build-aux/check-spacing.pl b/build-aux/check-spacing.pl
index 64a5dac..478e7ab 100755
--- a/build-aux/check-spacing.pl
+++ b/build-aux/check-spacing.pl
@@ -277,11 +277,22 @@ sub CheckMisalignment {
             my $code = $$paren_stack[-1][2];
             if ($pos != length($`)) {
                 my $pad = "";
+                my $indicator = "";
                 if ($. > $linenum + 1) {
                     $pad = " " x $pos . "...\n";
                 }
                 print "Misaligned line in parenthesis:\n";
-                print "$$file:$linenum-$.:\n$code$pad$$line\n";
+                print "$$file:$linenum-$.:\n$code$pad$$line";
+                if ($pos > length($`)) {
+                    $indicator = " " x length($`);
+                    $indicator .= "~" x ($pos - length($`));
+                    $indicator .= "^";
+                } else {
+                    $indicator = " " x $pos;
+                    $indicator .= "^";
+                    $indicator .= "~" x (length($`) - $pos);
+                }
+                print "$indicator\n";
                 $ret = 1;
             }
         }
-- 
2.17.1





More information about the libvir-list mailing list