From: Rafael Garcia-Suarez Date: Sun, 25 Feb 2007 15:04:17 +0000 (+0000) Subject: Factorize three regexps into one, using new regexp features X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=91798d18643cb4539dc3cf0a83f879bbe84d17c2;p=p5sagit%2Fp5-mst-13.2.git Factorize three regexps into one, using new regexp features (with some help from Yves Orton). (Now the compatibilty of this module with 5.8.x perls is doomed.) p4raw-id: //depot/perl@30395 --- diff --git a/lib/AutoSplit.pm b/lib/AutoSplit.pm index 1adb00d..bf92806 100644 --- a/lib/AutoSplit.pm +++ b/lib/AutoSplit.pm @@ -1,6 +1,6 @@ package AutoSplit; -use 5.009004; # due to "my $_" +use 5.009005; # due to "my $_" and new regexp features use Exporter (); use Config qw(%Config); use File::Basename (); @@ -147,14 +147,18 @@ if (defined (&Dos::UseLFN)) { my $Is_VMS = ($^O eq 'VMS'); # allow checking for valid ': attrlist' attachments -# (we use 'our' rather than 'my' here, due to the rather complex and buggy -# behaviour of lexicals with qr// and (??{$lex}) ) -our $nested; -$nested = qr{ \( (?: (?> [^()]+ ) | (??{ $nested }) )* \) }x; -our $one_attr = qr{ (?> (?! \d) \w+ (?:$nested)? ) (?:\s*\:\s*|\s+(?!\:)) }x; -our $attr_list = qr{ \s* : \s* (?: $one_attr )* }x; - +my $attr_list = qr{ + \s* : \s* + (?: + # one attribute + (?> # no backtrack + (?! \d) \w+ + (? \( (?: [^()]++ | (?&nested)++ )*+ \) ) ? + ) + (?: \s* : \s* | \s+ (?! :) ) + )* +}x; sub autosplit{ my($file, $autodir, $keep, $ckal, $ckmt) = @_;