diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-04-21 21:01:42 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-04-21 21:01:42 +0000 |
commit | 1839d50fad8582f4b27473a7dd8120d70eefe5ed (patch) | |
tree | ca5e8d3c50069d8767ed65fd70de340ae898358e /ext/re/re.xs | |
parent | 380e0b81e09ad752fe245d3a881f3c6fd5d1f3a7 (diff) | |
download | perl-1839d50fad8582f4b27473a7dd8120d70eefe5ed.tar.gz |
Merge the install and uninstall routines.
p4raw-id: //depot/perl@27935
Diffstat (limited to 'ext/re/re.xs')
-rw-r--r-- | ext/re/re.xs | 59 |
1 files changed, 29 insertions, 30 deletions
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); |