From 380e0b81e09ad752fe245d3a881f3c6fd5d1f3a7 Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Fri, 21 Apr 2006 20:38:15 +0000 Subject: [PATCH] Refactor re.pm slightly. This has no change to documented behaviour, but anyone mad enought to set ${^RE_DEBUG_FLAGS} and then do no re 'Debug'; will now find that it will load the debuging version of the regexp engine. p4raw-id: //depot/perl@27934 --- ext/re/re.pm | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/ext/re/re.pm b/ext/re/re.pm index 85ed9b6..96b1d63 100644 --- a/ext/re/re.pm +++ b/ext/re/re.pm @@ -1,6 +1,6 @@ package re; -our $VERSION = 0.06; +our $VERSION = 0.06_01; =head1 NAME @@ -136,6 +136,19 @@ my %flags = ( my $installed = 0; +sub _load_unload { + my $on = shift; + require XSLoader; + XSLoader::load('re'); + if ($on) { + install() unless $installed; + $installed=1; + } else { + uninstall() if $installed; + $installed=0; + } +} + sub bits { my $on = shift; my $bits = 0; @@ -148,8 +161,6 @@ sub bits { if ($s eq 'Debug' or $s eq 'Debugcolor') { setcolor() if $s eq 'Debugcolor'; ${^RE_DEBUG_FLAGS} = 0 unless defined ${^RE_DEBUG_FLAGS}; - require XSLoader; - XSLoader::load('re'); for my $idx ($idx+1..$#_) { if ($flags{$_[$idx]}) { if ($on) { @@ -163,25 +174,11 @@ sub bits { join(", ",sort { $flags{$a} <=> $flags{$b} } keys %flags ) ); } } - if ($on) { - install() unless $installed; - $installed = 1; - } elsif (!${^RE_DEBUG_FLAGS}) { - uninstall() if $installed; - $installed = 0; - } + _load_unload($on ? 1 : ${^RE_DEBUG_FLAGS}); last; } elsif ($s eq 'debug' or $s eq 'debugcolor') { setcolor() if $s eq 'debugcolor'; - require XSLoader; - XSLoader::load('re'); - if ($on) { - install() unless $installed; - $installed=1; - } else { - uninstall() if $installed; - $installed=0; - } + _load_unload($on); } elsif (exists $bitmask{$s}) { $bits |= $bitmask{$s}; } else { -- 2.7.4