This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Whitespace checks in mlint
authorH.Merijn Brand - Tux <h.m.brand@xs4all.nl>
Thu, 19 Apr 2018 07:54:38 +0000 (09:54 +0200)
committerH.Merijn Brand - Tux <h.m.brand@xs4all.nl>
Thu, 19 Apr 2018 07:54:38 +0000 (09:54 +0200)
I have discussed this with Rafael, and he kind of agrees. It is not yet
integrated upstream, but now that perl metaconfig has gone through these
changes, it is safe to have this guard in place to be consistent

bin/mlint

index bc4cce6..1ae25a5 100755 (executable)
--- a/bin/mlint
+++ b/bin/mlint
@@ -1704,12 +1704,29 @@ sub extract_dependencies {
                line: while (<FILE>) {
                        $line = $_;                                     # Save last processed unit line
                        if (s/^\?([\w\-]+)://) {        # We may have found a control line
-                               $proc = $Depend{$1};    # Look for a procedure to handle it
+                               my $type = $1;
+                               $proc = $Depend{$type}; # Look for a procedure to handle it
                                unless ($proc) {                # Unknown control line
-                                       $proc = $1;                     # p_unknown expects symbol in '$proc'
+                                       $proc = $type;                  # p_unknown expects symbol in '$proc'
                                        eval '&p_unknown';      # Signal error (metalint only)
                                        next line;                      # And go on next line
                                }
+                               if ($type =~ m/^[A-WYZ]$/ && m/^(\s+)\S/) { # No check on :X?, :RCS?
+                                   my $white = $1;
+                                   (my $f = $file) =~ s{.*/(?=U/)}{};
+                                   if ($type eq "O") {
+                                       # Obsolete, we don't care
+                                   }
+                                   elsif ($type =~ m/^[FT]$/) {
+                                       $white eq " " or
+                                           warn sprintf "%-32s %3d: Inconsistent whitespace (not a single space) after :$type?: %s", $f, $., $_;
+                                   }
+                                   else {
+                                       $white =~ m/^ / and
+                                           warn sprintf "%-32s %3d: Blanks after :$type? contain leading space(s): %s",
+                                               $f, $., $_;
+                                   }
+                               }
                                # Long lines may be escaped with a final backslash
                                $_ .= &complete_line(FILE) if s/\\\s*$//;
                                # Run macros substitutions