From: Andrew Main Date: Thu, 16 May 2013 15:11:41 +0000 (+0200) Subject: Partially revert 502e3aac. X-Git-Tag: rt83839 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=2a4f893f4fc19ecce6775df405a484004608a440;p=perl%2Fmodules%2Findirect.git Partially revert 502e3aac. Vincent: This fixes things, but I don't know why. This fixes RT #83806 and RT #83839. --- diff --git a/MANIFEST b/MANIFEST index df8b4e5..a2a49ed 100644 --- a/MANIFEST +++ b/MANIFEST @@ -27,6 +27,7 @@ t/45-memory.t t/46-stress.t t/47-stress-use.t t/50-external.t +t/51-dd-newlines.t t/91-pod.t t/92-pod-coverage.t t/93-pod-spelling.t diff --git a/indirect.xs b/indirect.xs index 3257b26..7878802 100644 --- a/indirect.xs +++ b/indirect.xs @@ -523,27 +523,12 @@ STATIC void indirect_map_delete(pTHX_ const OP *o) { /* --- Check functions ----------------------------------------------------- */ -STATIC STRLEN indirect_nextline(const char *s, STRLEN len) { - STRLEN i; - - for (i = 0; i < len; ++i) { - if (s[i] == '\n') { - ++i; - while (i < len && s[i] == '\r') - ++i; - break; - } - } - - return i; -} - STATIC int indirect_find(pTHX_ SV *name_sv, const char *line_bufptr, STRLEN *name_pos) { #define indirect_find(NSV, LBP, NP) indirect_find(aTHX_ (NSV), (LBP), (NP)) STRLEN name_len, line_len; const char *name, *name_end; const char *line, *line_end; - const char *p, *t, *u; + const char *p; line = SvPV_const(PL_linestr, line_len); line_end = line + line_len; @@ -572,26 +557,7 @@ STATIC int indirect_find(pTHX_ SV *name_sv, const char *line_bufptr, STRLEN *nam ++p; } - t = line; - u = t; - - /* If we're inside a string-like environment, we don't need to be smart for - * finding the positions of the tokens : as the line number will always be - * the line where the string began (or at least I hope so), and the line - * buffer points to the beginning of the string (likewise), we can just take - * the offset in this string as the position. */ - if (!PL_lex_inwhat) { - while (t <= p) { - STRLEN i = indirect_nextline(t, line_len); - if (i >= line_len) - break; - u = t; - t += i; - line_len -= i; - } - } - - *name_pos = p - u; + *name_pos = p - line; return 1; } diff --git a/t/20-good.t b/t/20-good.t index d958a13..d57de4f 100644 --- a/t/20-good.t +++ b/t/20-good.t @@ -9,7 +9,7 @@ package main; use strict; use warnings; -use Test::More tests => 109 * 8 + 10; +use Test::More tests => 112 * 8 + 10; BEGIN { delete $ENV{PERL_INDIRECT_PM_DISABLE} } @@ -426,3 +426,18 @@ my @stuff = sort Hlagh #### my @stuff = sort Hlagh ->new; +#### +sub { + my $self = shift; + return $self->new ? $self : undef; +} +#### +sub { + my $self = shift; + return $self ? $self->new : undef; +} +#### +sub { + my $self = shift; + return $_[0] ? undef : $self->new; +} diff --git a/t/51-dd-newlines.t b/t/51-dd-newlines.t new file mode 100644 index 0000000..47622e6 --- /dev/null +++ b/t/51-dd-newlines.t @@ -0,0 +1,33 @@ +#!perl + +use lib 't/lib'; +use VPIT::TestHelpers; + +BEGIN { + load_or_skip_all("Devel::Declare", 0.006007, undef); +} + +use Test::More tests => 1; + +sub foo { } + +sub foo_magic { + my($declarator, $offset) = @_; + $offset += Devel::Declare::toke_move_past_token($offset); + my $linestr = Devel::Declare::get_linestr(); + substr $linestr, $offset, 0, "\n\n"; + Devel::Declare::set_linestr($linestr); +} + +BEGIN { + Devel::Declare->setup_for("main", { foo => { const => \&foo_magic } }); +} + +no indirect ":fatal"; + +sub bar { + my $x; + foo; $x->m; +} + +ok 1;