Sophie

Sophie

distrib > Mageia > 8 > aarch64 > by-pkgid > 690d90ee47bca5a691da0ab73b7c1e07 > files > 3

colorgcc-1.4.5-4.mga8.src.rpm

--- colorgcc-1.4.5/colorgcc.pl.mgaconf	2019-01-21 18:15:21.484334871 -0500
+++ colorgcc-1.4.5/colorgcc.pl	2019-01-21 18:38:09.995184786 -0500
@@ -123,6 +123,26 @@ my($unfinishedQuote, $previousColor);
 
 sub initDefaults
 {
+  $compilerPaths{"color-gcc"} = "gcc";
+  $compilerPaths{"color-g++"} = "g++";
+  $compilerPaths{"color-cc"}  = "cc";
+  $compilerPaths{"color-c++"} = "c++";
+  $compilerPaths{"color-ccache"} = "ccache";
+  $compilerPaths{"color-gfortran"} = "gfortran";
+  $compilerPaths{"color-g77"} = "gfortran";
+  $compilerPaths{"color-f77"} = "gfortran";
+  $compilerPaths{"color-gcj"} = "gcj";
+
+  $compilerPaths{"colorgcc"} = "gcc";
+  $compilerPaths{"colorg++"} = "g++";
+  $compilerPaths{"colorcc"}  = "cc";
+  $compilerPaths{"colorc++"} = "c++";
+  $compilerPaths{"colorccache"} = "ccache";
+  $compilerPaths{"colorgfortran"} = "gfortran";
+  $compilerPaths{"colorg77"} = "gfortran";
+  $compilerPaths{"colorf77"} = "gfortran";
+  $compilerPaths{"colorgcj"} = "gcj";
+
   $options{"chainedPath"} = "0";
   $nocolor{"dumb"} = "true";
 
@@ -154,6 +174,9 @@ sub loadPreferences
 
   open(PREFS, "<$filename") || return;
 
+  my $gccVersion;
+  my $overrideCompilerPaths = 0;
+
   while(<PREFS>)
   {
     next if (m/^\#.*/);          # It's a comment.
@@ -171,6 +194,10 @@ sub loadPreferences
         $nocolor{$term} = 1;
       }
     }
+    elsif ($option eq "gccVersion")
+    {
+      $gccVersion = $value;
+    }
     elsif (defined $colors{$option})
     {
       $colors{$option} = color($value);
@@ -182,9 +209,15 @@ sub loadPreferences
     else
     {
       $compilerPaths{$option} = $value;
+      $overrideCompilerPaths  = 1;
     }
   }
   close(PREFS);
+
+  # Append "-<gccVersion>" to user-defined compilerPaths
+  if ($overrideCompilerPaths && $gccVersion) {
+      $compilerPaths{$_} .= "-$gccVersion" foreach (keys %compilerPaths);
+  }
 }
 
 sub srcscan
@@ -250,13 +283,14 @@ initDefaults();
 
 # Read the configuration file, if there is one.
 my $configFile = $ENV{"HOME"} . "/.colorgccrc";
+my $default_configFile = "/etc/colorgccrc";
 if (-f $configFile)
 {
   loadPreferences($configFile);
 }
-elsif (-f '/etc/colorgcc/colorgccrc')
+elsif (-f $default_configFile)
 {
-  loadPreferences('/etc/colorgcc/colorgccrc');
+  loadPreferences($default_configFile);
 }
 
 # Set our default output color.  This presumes that any unrecognized output
@@ -311,6 +345,10 @@ my $compiler =
 $compilerPaths{$progName} || findPath($progName) || 
 $compilerPaths{"gcc"}     || findPath("gcc");
 
+# Check that we don't reference self
+die "$compiler is self-referencing"
+    if ( -l $compiler and (stat $compiler)[1] == (stat $0)[1] );
+
 # Get the terminal type.
 my $terminal = $ENV{"TERM"} || "dumb";
 
--- colorgcc-1.4.5/colorgccrc.mgaconf	2019-01-21 18:39:15.117993429 -0500
+++ colorgcc-1.4.5/colorgccrc	2019-01-21 18:40:48.873717942 -0500
@@ -18,6 +18,10 @@
 # For example, srcColor: bold cyan on_yellow
 #
 
+# gccVersion: if defined, append "-<gccVersion>" to the compiler paths
+# defined hereunder. Otherwise, those paths remains as is set
+# gccVersion: GCC_VERSION
+
 # If you are using colorgcc in chain with other tools
 # e.g. ccache, uncomment this:
 chainedPath: 1
@@ -39,10 +43,14 @@ color-cc:  /usr/bin/cc
 #gcc: /usr/bin/gcc
 #c++: /usr/bin/c++
 #cc:  /usr/bin/cc
+# gfortran: /usr/bin/gfortran
+# g77: /usr/bin/gfortran
+# f77: /usr/bin/gfortran
+# gcj: /usr/bin/gcj
 
 # Don't do color if our terminal type ($TERM) is one of these.
 # (List all terminal types on one line, seperated by whitespace.)
-nocolor: dumb
+nocolor: dumb emacs
 
 # Text between ` and ' is usually source code.
 srcColor: bold cyan