forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
colorgcc-1.3.2-gentoo-two.patch
75 lines (65 loc) · 1.91 KB
/
colorgcc-1.3.2-gentoo-two.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
--- colorgcc.r9 2003-09-21 12:14:48.000000000 -0700
+++ colorgcc 2003-09-21 13:11:22.000000000 -0700
@@ -95,6 +95,7 @@
use Cwd 'abs_path';
my(%nocolor, %colors, %compilerPaths);
+my($unfinishedQuote, $previousColor);
sub initDefaults
{
@@ -159,14 +160,37 @@
my($line, $normalColor) = @_;
+ if (defined $normalColor)
+ {
+ $previousColor = $normalColor;
+ }
+ else
+ {
+ $normalColor = $previousColor;
+ }
+
my($srcon) = color("reset") . $colors{"srcColor"};
my($srcoff) = color("reset") . $normalColor;
- $line = $normalColor . $line;
+ $line = ($unfinishedQuote? $srcon : $normalColor) . $line;
- # This substitute replaces `foo' with `AfooB' where A is the escape
+ # These substitutions replaces `foo' with `AfooB' where A is the escape
# sequence that turns on the the desired source color, and B is the
# escape sequence that returns to $normalColor.
+
+ # Handle multi-line quotes.
+ if ($unfinishedQuote) {
+ if ($line =~ s/^([^\`]*?)\'/$1$srcoff\'/)
+ {
+ $unfinishedQuote = 0;
+ }
+ }
+ if ($line =~ s/\`([^\']*?)$/\`$srcon$1/)
+ {
+ $unfinishedQuote = 1;
+ }
+
+ # Single line quoting.
$line =~ s/\`(.*?)\'/\`$srcon$1$srcoff\'/g;
print($line, color("reset"));
@@ -190,6 +214,10 @@
loadPreferences('/etc/colorgcc/colorgccrc');
}
+# Set our default output color. This presumes that any unrecognized output
+# is an error.
+$previousColor = $colors{"errorMessageColor"};
+
# Figure out which compiler to invoke based on our program name.
$0 =~ m%.*/(.*)$%;
my $progName = $1 || $0;
@@ -281,10 +309,9 @@
# No line number, treat as an "introductory" line of text.
srcscan($_, $colors{"introColor"});
}
- else # Anything else.
+ else # Anything else.
{
- # Doesn't seem to be a warning or an error. Print normally.
- print(color("reset"), $_);
+ srcscan($_, undef);
}
}