[Bast-commits] r5894 - in Devel-Declare/1.000/trunk: .
lib/Devel/Declare/Context
rafl at dev.catalyst.perl.org
rafl at dev.catalyst.perl.org
Sat Apr 18 08:42:07 GMT 2009
Author: rafl
Date: 2009-04-18 09:42:06 +0100 (Sat, 18 Apr 2009)
New Revision: 5894
Modified:
Devel-Declare/1.000/trunk/Declare.xs
Devel-Declare/1.000/trunk/lib/Devel/Declare/Context/Simple.pm
Log:
Allow extracting strings going over multiple lines using scan_str.
Modified: Devel-Declare/1.000/trunk/Declare.xs
===================================================================
--- Devel-Declare/1.000/trunk/Declare.xs 2009-04-18 08:42:00 UTC (rev 5893)
+++ Devel-Declare/1.000/trunk/Declare.xs 2009-04-18 08:42:06 UTC (rev 5894)
@@ -187,8 +187,17 @@
}
int dd_toke_scan_str(pTHX_ int offset) {
+ int remaining = sv_len(PL_linestr) - offset;
+ SV* line_copy = newSVsv(PL_linestr);
char* base_s = SvPVX(PL_linestr) + offset;
char* s = scan_str(base_s, FALSE, FALSE);
+ if (s != base_s && sv_len(PL_lex_stuff) > remaining) {
+ int ret = (s - SvPVX(PL_linestr)) + remaining;
+ sv_catsv(line_copy, PL_linestr);
+ dd_set_linestr(aTHX_ SvPV_nolen(line_copy));
+ SvREFCNT_dec(line_copy);
+ return ret;
+ }
return s - base_s;
}
Modified: Devel-Declare/1.000/trunk/lib/Devel/Declare/Context/Simple.pm
===================================================================
--- Devel-Declare/1.000/trunk/lib/Devel/Declare/Context/Simple.pm 2009-04-18 08:42:00 UTC (rev 5893)
+++ Devel-Declare/1.000/trunk/lib/Devel/Declare/Context/Simple.pm 2009-04-18 08:42:06 UTC (rev 5894)
@@ -92,14 +92,7 @@
my $length = Devel::Declare::toke_scan_str($self->offset);
my $proto = Devel::Declare::get_lex_stuff();
Devel::Declare::clear_lex_stuff();
- if( $length < 0 ) {
- # Need to scan ahead more
- $linestr .= $self->get_linestr();
- $length = rindex($linestr, ")") - $self->offset + 1;
- }
- else {
- $linestr = $self->get_linestr();
- }
+ $linestr = $self->get_linestr();
substr($linestr, $self->offset, $length) = '';
$self->set_linestr($linestr);
More information about the Bast-commits
mailing list