From 1839d50fad8582f4b27473a7dd8120d70eefe5ed Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Fri, 21 Apr 2006 21:01:42 +0000 Subject: Merge the install and uninstall routines. p4raw-id: //depot/perl@27935 --- ext/re/re.xs | 59 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 29 insertions(+), 30 deletions(-) (limited to 'ext/re/re.xs') diff --git a/ext/re/re.xs b/ext/re/re.xs index 11239d7e59..014b8b7063 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); -- cgit v1.2.1