X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=bin%2Fblhc;h=2ae115015036a3a2feecc836578c59057d89f196;hb=0c6b6b89c3bc35a85aa1bef12ef4e6323085e4b3;hp=f4a242ce17fb3e29717031b7692dc7719b510af7;hpb=5f36c99fe17184b3b10edf4d89b8d8f82cedd175;p=blhc%2Fblhc.git diff --git a/bin/blhc b/bin/blhc index f4a242c..2ae1150 100755 --- a/bin/blhc +++ b/bin/blhc @@ -311,7 +311,7 @@ sub is_non_verbose_build { $file =~ m{/([a-zA-Z0-9._-]+)$}; $file = $1; - if ($next_line =~ /\Q$file\E/ and $next_line =~ /$cc_regex/) { + if ($next_line =~ /\Q$file\E/ and $next_line =~ /$cc_regex/o) { # We still have to skip the current line as it doesn't contain any # compiler commands. ${$skip_ref} = 1; @@ -450,17 +450,19 @@ while (my $line = <>) { } # Ignore compiler warnings for now. - next if $line =~ /$warning_regex/; - - # Remove all ANSI color sequences which are sometimes used in non-verbose - # builds. - $line = Term::ANSIColor::colorstrip($line); - # Also strip '\0xf' (delete previous character), used by Elinks' build - # system. - $line =~ s/\x0f//g; - # And "ESC(B" which seems to be used on armhf and hurd (not sure what it - # does). - $line =~ s/\033\(B//g; + next if $line =~ /$warning_regex/o; + + if ($line =~ /\033/) { # esc + # Remove all ANSI color sequences which are sometimes used in + # non-verbose builds. + $line = Term::ANSIColor::colorstrip($line); + # Also strip '\0xf' (delete previous character), used by Elinks' build + # system. + $line =~ s/\x0f//g; + # And "ESC(B" which seems to be used on armhf and hurd (not sure what + # it does). + $line =~ s/\033\(B//g; + } # Check if this line indicates a non verbose build. my $non_verbose = is_non_verbose_build($line); @@ -469,12 +471,13 @@ while (my $line = <>) { # line. parse_line() is slow, only use it when necessary. my @line = (not $line =~ /;/) ? ($line) - : Text::ParseWords::parse_line(';', 1, $line); + : map { + # Ensure newline at the line end - necessary for correct + # parsing later. + $_ =~ s/\s+$//; + $_ .= "\n"; + } Text::ParseWords::parse_line(';', 1, $line); foreach $line (@line) { - # Add newline, drop all other whitespace at the end of a line. - $line =~ s/\s+$//; - $line .= "\n"; - if ($continuation) { $continuation = 0; @@ -501,7 +504,7 @@ while (my $line = <>) { } # Ignore lines with no compiler commands. - next if $line !~ /\b$cc_regex(?:\s|\\)/ and not $non_verbose; + next if $line !~ /\b$cc_regex(?:\s|\\)/o and not $non_verbose; # Ignore false positives. # @@ -512,8 +515,8 @@ while (my $line = <>) { (?:C|c)ompiler[\s.]*:?\s+ $cc_regex (?:\s-std=[a-z0-9:+]+)?\s*$ - /x - or $line =~ /^\s*(?:- )?(?:HOST_)?(?:CC|CXX)\s*=\s*$cc_regex\s*$/ + /xo + or $line =~ /^\s*(?:- )?(?:HOST_)?(?:CC|CXX)\s*=\s*$cc_regex\s*$/o or $line =~ /^\s*-- Check for working (?:C|CXX) compiler: / or $line =~ /^\s*(?:echo )?Using [A-Z_]+\s*=\s*/; # `make` output. @@ -596,7 +599,7 @@ for (my $i = 0; $i < scalar @input; $i++) { # Remove everything until and including the compiler command. Makes checks # easier and faster. - $line =~ s/^.*?$cc_regex//; + $line =~ s/^.*?$cc_regex//o; # Skip unnecessary tests when only preprocessing. my $flag_preprocess = 0; @@ -616,7 +619,7 @@ for (my $i = 0; $i < scalar @input; $i++) { } # Get all file extensions on this line. - my @extensions = $line =~ /$file_extension_regex/g; + my @extensions = $line =~ /$file_extension_regex/go; # Ignore all unknown extensions to speedup the search below. @extensions = grep { exists $extension{$_} } @extensions;