]> ruderich.org/simon Gitweb - blhc/blhc.git/blobdiff - bin/blhc
Strip trailing whitspace only when necessary.
[blhc/blhc.git] / bin / blhc
index 5443eef5a4226db9e3c64a315d602b0eb470131f..2ae115015036a3a2feecc836578c59057d89f196 100755 (executable)
--- a/bin/blhc
+++ b/bin/blhc
@@ -452,15 +452,17 @@ while (my $line = <>) {
     # Ignore compiler warnings for now.
     next if $line =~ /$warning_regex/o;
 
-    # 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;
+    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;