From: Nicholas Clark Date: Fri, 21 Apr 2006 21:01:42 +0000 (+0000) Subject: Merge the install and uninstall routines. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1839d50fad8582f4b27473a7dd8120d70eefe5ed;p=p5sagit%2Fp5-mst-13.2.git Merge the install and uninstall routines. p4raw-id: //depot/perl@27935 --- diff --git a/ext/re/re.pm b/ext/re/re.pm index 96b1d63..fc78451 100644 --- a/ext/re/re.pm +++ b/ext/re/re.pm @@ -140,13 +140,7 @@ sub _load_unload { my $on = shift; require XSLoader; XSLoader::load('re'); - if ($on) { - install() unless $installed; - $installed=1; - } else { - uninstall() if $installed; - $installed=0; - } + install($on); } sub bits { diff --git a/ext/re/re.xs b/ext/re/re.xs index 11239d7..014b8b7 100644 --- a/ext/re/re.xs +++ b/ext/re/re.xs @@ -25,6 +25,7 @@ END_EXTERN_C typedef struct { int x_oldflag; /* debug flag */ + unsigned int x_state; } my_cxt_t; START_MY_CXT @@ -32,31 +33,33 @@ START_MY_CXT #define oldflag (MY_CXT.x_oldflag) static void -uninstall(pTHX) +install(pTHX_ unsigned int new_state) { dMY_CXT; - PL_regexecp = Perl_regexec_flags; - PL_regcompp = Perl_pregcomp; - PL_regint_start = Perl_re_intuit_start; - PL_regint_string = Perl_re_intuit_string; - PL_regfree = Perl_pregfree; - - if (!oldflag) - PL_debug &= ~DEBUG_r_FLAG; -} - -static void -install(pTHX) -{ - dMY_CXT; - PL_colorset = 0; /* Allow reinspection of ENV. */ - PL_regexecp = &my_regexec; - PL_regcompp = &my_regcomp; - PL_regint_start = &my_re_intuit_start; - PL_regint_string = &my_re_intuit_string; - PL_regfree = &my_regfree; - oldflag = PL_debug & DEBUG_r_FLAG; - PL_debug |= DEBUG_r_FLAG; + if(new_state == MY_CXT.x_state) + return; + + if (new_state) { + PL_colorset = 0; /* Allow reinspection of ENV. */ + PL_regexecp = &my_regexec; + PL_regcompp = &my_regcomp; + PL_regint_start = &my_re_intuit_start; + PL_regint_string = &my_re_intuit_string; + PL_regfree = &my_regfree; + oldflag = PL_debug & DEBUG_r_FLAG; + PL_debug |= DEBUG_r_FLAG; + } else { + PL_regexecp = Perl_regexec_flags; + PL_regcompp = Perl_pregcomp; + PL_regint_start = Perl_re_intuit_start; + PL_regint_string = Perl_re_intuit_string; + PL_regfree = Perl_pregfree; + + if (!oldflag) + PL_debug &= ~DEBUG_r_FLAG; + } + + MY_CXT.x_state = new_state; } MODULE = re PACKAGE = re @@ -68,11 +71,7 @@ BOOT: void -install() - CODE: - install(aTHX); - -void -uninstall() +install(new_state) + unsigned int new_state; CODE: - uninstall(aTHX); + install(aTHX_ new_state);