Change 13007 by jhi@alpha on 2001/11/14 22:05:01
Upgrade to Switch 2.06.
Affected files ...
.... //depot/perl/lib/Switch.pm#7 edit
.... //depot/perl/lib/Switch/Changes#3 edit
.... //depot/perl/lib/Switch/README#3 edit
.... //depot/perl/lib/Switch/t/nested.t#3 edit
Differences ...
==== //depot/perl/lib/Switch.pm#7 (text) ====
Index: perl/lib/Switch.pm
--- perl/lib/Switch.pm.~1~ Wed Nov 14 15:15:05 2001
+++ perl/lib/Switch.pm Wed Nov 14 15:15:05 2001
@@ -4,7 +4,7 @@
use vars qw($VERSION);
use Carp;
-$VERSION = '2.05';
+$VERSION = '2.06';
# LOAD FILTERING MODULE...
@@ -74,6 +74,16 @@
return !$ishash;
}
+
+my $EOP = qr/\n\n|\Z/;
+my $CUT = qr/\n=cut.*$EOP/;
+my $pod_or_DATA = qr/ ^=(?:head[1-4]|item) .*? $CUT
+ | ^=pod .*? $CUT
+ | ^=for .*? $EOP
+ | ^=begin \s* (\S+) .*? \n=end \s* \1 .*? $EOP
+ | ^__(DATA|END)__\n.*
+ /smx;
+
my $casecounter = 1;
sub filter_blocks
{
@@ -89,12 +99,15 @@
$text .= q{use Switch 'noimport'};
next component;
}
- my @pos = Text::Balanced::_match_quotelike(\$source,qr/\s*/,1,1);
+ my @pos = Text::Balanced::_match_quotelike(\$source,qr/\s*/,1,0);
if (defined $pos[0])
{
$text .= " " . substr($source,$pos[2],$pos[18]-$pos[2]);
next component;
}
+ if ($source =~ m/\G\s*($pod_or_DATA)/gc) {
+ next component;
+ }
@pos = Text::Balanced::_match_variable(\$source,qr/\s*/);
if (defined $pos[0])
{
@@ -149,7 +162,7 @@
$code =~ s {^\s*@} { \@};
$text .= " $code)";
}
- elsif ( @pos =
Text::Balanced::_match_quotelike(\$source,qr/\s*/,1,1)) {
+ elsif ( @pos =
+Text::Balanced::_match_quotelike(\$source,qr/\s*/,1,0)) {
my $code = substr($source,$pos[2],$pos[18]-$pos[2]);
$code =
filter_blocks($code,line(substr($source,0,$pos[2]),$line));
$code =~ s {^\s*m} { qr} ||
@@ -186,7 +199,7 @@
next component;
}
- $source =~ m/\G(\s*(\w+|#.*\n|\W))/gc;
+ $source =~ m/\G(\s*(-[sm]\s+|\w+|#.*\n|\W))/gc;
$text .= $1;
}
$text;
@@ -341,7 +354,8 @@
return 1;
}
-sub case($) { $::_S_W_I_T_C_H->(@_); }
+sub case($) { local $SIG{__WARN__} = \&carp;
+ $::_S_W_I_T_C_H->(@_); }
# IMPLEMENT __
@@ -473,8 +487,8 @@
=head1 VERSION
-This document describes version 2.05 of Switch,
-released September 3, 2001.
+This document describes version 2.06 of Switch,
+released November 14, 2001.
=head1 SYNOPSIS
@@ -825,6 +839,12 @@
There are undoubtedly serious bugs lurking somewhere in code this funky :-)
Bug reports and other feedback are most welcome.
+=head1 LIMITATION
+
+Due to the heuristic nature of Switch.pm's source parsing, the presence
+of regexes specified with raw C<?...?> delimiters may cause mysterious
+errors. The workaround is to use C<m?...?> instead.
+
=head1 COPYRIGHT
Copyright (c) 1997-2001, Damian Conway. All Rights Reserved.
==== //depot/perl/lib/Switch/Changes#3 (xtext) ====
Index: perl/lib/Switch/Changes
--- perl/lib/Switch/Changes.~1~ Wed Nov 14 15:15:05 2001
+++ perl/lib/Switch/Changes Wed Nov 14 15:15:05 2001
@@ -48,3 +48,14 @@
- Changed licence for inclusion in core distribution
- Added new test file for non-fallthrough and nested switches
+
+
+2.06 Wed Nov 14 16:18:54 2001
+
+ - Fixed parsing of ternary operators in Switch'ed source code
+ (at the expense of no longer correctly parsing ?...? regexes)
+ (thanks Mark)
+
+ - Fixed the parsing of embedded POD (thanks Brent)
+
+ - Fixed bug encountered when -s or -m file test used (thanks Jochen)
==== //depot/perl/lib/Switch/README#3 (text) ====
Index: perl/lib/Switch/README
--- perl/lib/Switch/README.~1~ Wed Nov 14 15:15:05 2001
+++ perl/lib/Switch/README Wed Nov 14 15:15:05 2001
@@ -1,5 +1,5 @@
==============================================================================
- Release of version 2.05 of Switch
+ Release of version 2.06 of Switch
==============================================================================
@@ -26,12 +26,16 @@
==============================================================================
-CHANGES IN VERSION 2.05
+CHANGES IN VERSION 2.06
+
+ - Fixed parsing of ternary operators in Switch'ed source code
+ (at the expense of no longer correctly parsing ?...? regexes)
+ (thanks Mark)
- - Changed licence for inclusion in core distribution
+ - Fixed the parsing of embedded POD (thanks Brent)
- - Added new test file for non-fallthrough and nested switches
+ - Fixed bug encountered when -s or -m file test used (thanks Jochen)
==============================================================================
==== //depot/perl/lib/Switch/t/nested.t#3 (xtext) ====
Index: perl/lib/Switch/t/nested.t
--- perl/lib/Switch/t/nested.t.~1~ Wed Nov 14 15:15:05 2001
+++ perl/lib/Switch/t/nested.t Wed Nov 14 15:15:05 2001
@@ -14,6 +14,15 @@
{
switch ([$count])
{
+
+=pod
+
+=head1 Test
+
+We also test if Switch is POD-friendly here
+
+=cut
+
case qr/\d/ {
switch ($count) {
case 1 { print "ok 1\n" }
@@ -23,3 +32,11 @@
case 'four' { print "ok 4\n" }
}
}
+
+__END__
+
+=head1 Another test
+
+Still friendly???
+
+=cut
End of Patch.