X-Git-Url: https://ruderich.org/simon/gitweb/?p=blhc%2Fblhc.git;a=blobdiff_plain;f=bin%2Fblhc;fp=bin%2Fblhc;h=52a846957fae19d5d5f2018725dfd985b39420ee;hp=140d2adcf2df7ad80c0bc2f8cfdc4d832c055ecd;hb=ceef2f83a375cace7ee2e1fc7a27dadcbc75737a;hpb=189d593d45a3cab37a1908c2ae6c0c0d0916d60d diff --git a/bin/blhc b/bin/blhc index 140d2ad..52a8469 100755 --- 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