]> ruderich.org/simon Gitweb - blhc/blhc.git/blobdiff - bin/blhc
Also split commands on && and ||
[blhc/blhc.git] / bin / blhc
index 140d2adcf2df7ad80c0bc2f8cfdc4d832c055ecd..52a846957fae19d5d5f2018725dfd985b39420ee 100755 (executable)
--- a/bin/blhc
+++ b/bin/blhc
@@ -341,6 +341,26 @@ my $option_color;
 
 # FUNCTIONS
 
+sub split_line {
+    my ($line) = @_;
+
+    my @work = ($line);
+    foreach my $delim (';', '&&', '||') {
+        my @x;
+        foreach (@work) {
+            push @x, Text::ParseWords::parse_line(qr/\Q$delim\E/, 1, $_);
+        }
+        @work = @x;
+    }
+
+    return map {
+                       # Ensure newline at the line end - necessary for
+                       # correct parsing later.
+                       $_ =~ s/\s+$//;
+                       $_ .= "\n";
+    } @work;
+}
+
 sub error_flags {
     my ($message, $missing_flags_ref, $flag_renames_ref, $line, $number) = @_;
 
@@ -971,16 +991,12 @@ foreach my $file (@ARGV) {
         $non_verbose |= is_non_verbose_build($line, \$skip);
         next if $skip;
 
-        # One line may contain multiple commands (";"). Treat each one as
-        # single line. parse_line() is slow, only use it when necessary.
-        my @line = (index($line, ';') == -1)
+        # Treat each command as a single line so we don't ignore valid
+        # commands when handling false positives. split_line() is slow, only
+        # use it when necessary.
+        my @line = ($line !~ /(?:;|&&|\|\|)/)
                  ? ($line)
-                 : map {
-                       # Ensure newline at the line end - necessary for
-                       # correct parsing later.
-                       $_ =~ s/\s+$//;
-                       $_ .= "\n";
-                   } Text::ParseWords::parse_line(';', 1, $line);
+                 : split_line($line);
         foreach my $line (@line) {
             if ($continuation) {
                 $continuation = 0;
@@ -1029,6 +1045,8 @@ foreach my $file (@ARGV) {
                                 # optional compiler options, don't allow
                                 # "everything" here to prevent false negatives
                                 \s*(?:\s-\S+)*\s*$}xo;
+            # `echo` is never a compiler command
+            next if $line =~ /^\s*echo\s/;
             # `moc-qt4`/`moc-qt5` contain '-I.../linux-g++' in their command
             # line (or similar for other architectures) which gets recognized
             # as a compiler line, but `moc-qt*` is only a preprocessor for Qt