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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch definitely indicates the correct position for misaligned
stuff.

Signed-off-by: Shi Lei <shi_lei@xxxxxxxxxxxxxx>
---
 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


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux