]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix minor issue with -wma
authorSteve Hancock <perltidy@users.sourceforge.net>
Mon, 26 Aug 2024 23:34:57 +0000 (16:34 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Mon, 26 Aug 2024 23:34:57 +0000 (16:34 -0700)
lib/Perl/Tidy/Tokenizer.pm

index 02168ab1ac2afb4759e1309fd393b8a605766f42..ab21de1749acde3979554f0ab61853b66b1aef32 100644 (file)
@@ -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';