Facebook Embed

02 January 2014

colordiff trailing whitespace again

Why do I keep on having to do this?

I think I shall leave this version of the patch right here for future reference.

--- /usr/bin/colordiff 2010-06-01 12:47:41.000000000 -0700
+++ colordiff 2014-01-02 13:29:03.954751310 -0800
@@ -61,4 +61,5 @@
 my $diff_stuff = $colour{magenta};
 my $cvs_stuff  = $colour{darkyellow};
+my $trailing_whitespace = "\033[0;41m";
 
 # Locations for personal and system-wide colour configurations
@@ -311,4 +312,5 @@
 
 foreach (@inputstream) {
+    my $added_line = 0;
     if ($diff_type eq 'diff') {
         if (/^</) {
@@ -317,4 +319,5 @@
         elsif (/^>/) {
             print "$file_new";
+            $added_line = 1;
         }
         elsif (/^[0-9]/) {
@@ -337,4 +340,5 @@
         elsif (/^\+ /) {
             print "$file_new";
+            $added_line = 1;
         }
         elsif (/^\*{4,}/) {
@@ -379,4 +383,5 @@
         elsif (/^\+/) {
             print "$file_new";
+            $added_line = 1;
         }
         elsif (/^\@/) {
@@ -406,4 +411,5 @@
             elsif ($sepchars eq ' >') {
                 print "$file_new";
+                $added_line = 1;
             }
             else {
@@ -426,4 +432,5 @@
         $_ =~ s/(\{\+[^]]*?\+\})/$file_new$1$colour{off}/g;
     }
+    s/(\s+)$/$trailing_whitespace$1/ if $added_line;
     s/$/$colour{off}/;
     print "$_";

kthxbai!

No comments: