summaryrefslogtreecommitdiff
path: root/ext/re
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-09-11 21:29:53 +0100
committerNicholas Clark <nick@ccl4.org>2009-09-11 21:29:53 +0100
commitec781434013114c8340920837746df54b89f0d5f (patch)
tree84dce93259e633b77bf8c92c3ffca487c71cb667 /ext/re
parent7229c7f428510c1c410594e88b517785713f9df9 (diff)
downloadperl-ec781434013114c8340920837746df54b89f0d5f.tar.gz
Always load the re.xs code, unless we're running under miniperl.
This is a lot simpler than the previous implementation, which would lazy load the XS code only if it was needed, and then jump through more hopes to try to give the user a reasonable error message if it failed. In the real world, people either have a full perl installed with the re extension, or their install is already horribly broken. Don't let code related to bootstrapping the core build pollute the installation.
Diffstat (limited to 'ext/re')
-rw-r--r--ext/re/re.pm52
1 files changed, 17 insertions, 35 deletions
diff --git a/ext/re/re.pm b/ext/re/re.pm
index 6331fb90f2..54d504f55e 100644
--- a/ext/re/re.pm
+++ b/ext/re/re.pm
@@ -4,11 +4,9 @@ package re;
use strict;
use warnings;
-our $VERSION = "0.09";
+our $VERSION = "0.10";
our @ISA = qw(Exporter);
-my @XS_FUNCTIONS = qw(regmust);
-my %XS_FUNCTIONS = map { $_ => 1 } @XS_FUNCTIONS;
-our @EXPORT_OK = (@XS_FUNCTIONS,
+our @EXPORT_OK = ('regmust',
qw(is_regexp regexp_pattern
regname regnames regnames_count));
our %EXPORT_OK = map { $_ => 1 } @EXPORT_OK;
@@ -80,34 +78,26 @@ $flags{More} = $flags{MORE} = $flags{All} | $flags{TRIEC} | $flags{TRIEM} | $fla
$flags{State} = $flags{DUMP} | $flags{EXECUTE} | $flags{STATE};
$flags{TRIE} = $flags{DUMP} | $flags{EXECUTE} | $flags{TRIEC};
-my $installed;
-my $installed_error;
-
-sub _do_install {
- if ( ! defined($installed) ) {
- require XSLoader;
- $installed = eval { XSLoader::load('re', $VERSION) } || 0;
- $installed_error = $@;
- }
+if (defined &DynaLoader::boot_DynaLoader) {
+ require XSLoader;
+ XSLoader::load( __PACKAGE__, $VERSION);
}
+# else we're miniperl
+# We need to work for miniperl, because the XS toolchain uses Text::Wrap, which
+# uses re 'taint'.
sub _load_unload {
my ($on)= @_;
if ($on) {
- _do_install();
- if ( ! $installed ) {
- die "'re' not installed!? ($installed_error)";
- } else {
- # We call install() every time, as if we didn't, we wouldn't
- # "see" any changes to the color environment var since
- # the last time it was called.
-
- # install() returns an integer, which if casted properly
- # in C resolves to a structure containing the regex
- # hooks. Setting it to a random integer will guarantee
- # segfaults.
- $^H{regcomp} = install();
- }
+ # We call install() every time, as if we didn't, we wouldn't
+ # "see" any changes to the color environment var since
+ # the last time it was called.
+
+ # install() returns an integer, which if casted properly
+ # in C resolves to a structure containing the regex
+ # hooks. Setting it to a random integer will guarantee
+ # segfaults.
+ $^H{regcomp} = install();
} else {
delete $^H{regcomp};
}
@@ -146,14 +136,6 @@ sub bits {
last;
} elsif (exists $bitmask{$s}) {
$bits |= $bitmask{$s};
- } elsif ($XS_FUNCTIONS{$s}) {
- _do_install();
- if (! $installed) {
- require Carp;
- Carp::croak("\"re\" function '$s' not available");
- }
- require Exporter;
- re->export_to_level(2, 're', $s);
} elsif ($EXPORT_OK{$s}) {
require Exporter;
re->export_to_level(2, 're', $s);