From afbf593814070a6c407bd21e3edc0a14da318415 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Mon, 26 Aug 2024 16:34:57 -0700 Subject: [PATCH] fix minor issue with -wma --- lib/Perl/Tidy/Tokenizer.pm | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index 02168ab1..ab21de17 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -7752,7 +7752,6 @@ sub scan_bare_identifier_do { # we have to back up one pretoken at a :: since each : is one pretoken if ( $tok eq '::' ) { $i_beg-- } - if ( $tok eq '->' ) { $i_beg-- } my $pos_beg = $rtoken_map->[$i_beg]; pos($input_line) = $pos_beg; @@ -7764,9 +7763,8 @@ sub scan_bare_identifier_do { if ( $input_line =~ m{ \G\s* # start at pos - ( (?:\w*(?:'|::)) )* # $1 = maybe package name like A:: A::B:: or A' - (?:(?:->)? # maybe followed by '->' - (\w+))? # $2 = maybe followed by sub name + ( (?:\w*(?:'|::))* ) # $1 = maybe package name like A:: A::B:: or A' + (\w+)? # $2 = maybe followed by sub name }gcx ) { @@ -7780,9 +7778,19 @@ sub scan_bare_identifier_do { my $sub_name = EMPTY_STRING; if ( defined($2) ) { $sub_name = $2; } - if ( defined($1) ) { + if ( defined($1) && length($1) ) { $package = $1; + # patch: check for package call A::B::C-> + # in this case, C is part of the package name + if ($sub_name) { + if ( $input_line =~ m{ \G\s*(?:->) }gcx ) { + $package .= $sub_name; + $sub_name = EMPTY_STRING; + } + pos($input_line) = $pos; + } + # patch: don't allow isolated package name which just ends # in the old style package separator (single quote). Example: # use CGI':all'; -- 2.39.5