Alright, attached are two patches. One contains a fix for a thing i
noticed while debugging, the other fixes the colors. :)
From ecc5677de274efd2ddc45cc539da47efec39e70b Mon Sep 17 00:00:00 2001
From: Christian Walde <walde.christian@googlemail.com>
Date: Sun, 22 Jul 2012 15:01:10 +0200
Subject: [PATCH 2/2] implement color fallback for Win32
- Win32::Console::ANSI is an XS module that rewrites STDOUT handling to
filter for color codes. Simply loading it is sufficient.
- Term::ANSIColor is only loaded on non-win32 systems or those equipped
with W::C::A to avoid redefinition warnings when registering the
pass-through function.
---
lib/Regexp/Debugger.pm | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/Regexp/Debugger.pm b/lib/Regexp/Debugger.pm
index 8e6ecd8..ba64aca 100644
--- a/lib/Regexp/Debugger.pm
+++ b/lib/Regexp/Debugger.pm
@@ -89,7 +89,9 @@ my $heatmaps_invisible;
# Simulate Term::ANSIColor (badly, if necessary)...
CHECK {
- if (!eval{ require Term::ANSIColor }) {
+ my $can_color = ( $^O ne 'MSWin32' or eval { require Win32::Console::ANSI } );
+ $can_color = eval { require Term::ANSIColor } if $can_color;
+ if ( !$can_color ) {
*Term::ANSIColor::colored = sub { return shift };
$MATCH_DRAG = '_';
$heatmaps_invisible = 1;
--
1.7.10.msysgit.1
From 448c0cb659538eff900bc697256e6c82081a2522 Mon Sep 17 00:00:00 2001
From: Christian Walde <walde.christian@googlemail.com>
Date: Sun, 22 Jul 2012 14:38:06 +0200
Subject: [PATCH 1/2] $ENV{HOME} is not reliable, so let's use File::HomeDir
if available, or just skip that part
---
lib/Regexp/Debugger.pm | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/Regexp/Debugger.pm b/lib/Regexp/Debugger.pm
index 7ced7cb..8e6ecd8 100644
--- a/lib/Regexp/Debugger.pm
+++ b/lib/Regexp/Debugger.pm
@@ -157,9 +157,12 @@ sub _load_config {
my $explicit_config_ref = shift();
my %config;
+ my $home_dir = $ENV{HOME};
+ $home_dir ||= File::HomeDir->my_home if eval { require File::HomeDir };
+
# Find config file...
CONFIG_FILE:
- for my $config_file ('.rxrx', "$ENV{HOME}/.rxrx") {
+ for my $config_file ( '.rxrx', ( $home_dir ? "$home_dir/.rxrx" : () ) ) {
# Is this a readable config file???
open my $fh, '<', $config_file
--
1.7.10.msysgit.1