]> git.donarmstrong.com Git - perltidy.git/commitdiff
fix sub scan_identifier_do to use \w instead of [_A-Za-z]
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 22 Mar 2020 14:43:13 +0000 (07:43 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 22 Mar 2020 14:43:13 +0000 (07:43 -0700)
lib/Perl/Tidy/Tokenizer.pm

index a82aa9d8a685cd7dfaff21c0376939c5d12691dc..43e1ec4d4167f63a044032fbea25483307fcea4f 100644 (file)
@@ -5790,7 +5790,7 @@ sub scan_identifier_do {
     my $in_prototype_or_signature = $container_type =~ /^sub/;
 
     # these flags will be used to help figure out the type:
-    my $saw_alpha = ( $tok =~ /^[A-Za-z_]/ );
+    my $saw_alpha = ( $tok =~ /^\w/ );
     my $saw_type;
 
     # allow old package separator (') except in 'use' statement
@@ -5826,7 +5826,7 @@ sub scan_identifier_do {
         elsif ( $tok eq '::' ) {
             $id_scan_state = 'A';
         }
-        elsif ( $tok =~ /^[A-Za-z_]/ ) {
+        elsif ( $tok =~ /^\w/ ) {
             $id_scan_state = ':';
         }
         elsif ( $tok eq '->' ) {
@@ -5877,7 +5877,7 @@ sub scan_identifier_do {
             elsif ( ( $tok =~ /^[\@\%\&\*]$/ ) && $identifier =~ /\-\>$/ ) {
                 $identifier .= $tok;
             }
-            elsif ( $tok =~ /^[A-Za-z_]/ ) {    # alphanumeric ..
+            elsif ( $tok =~ /^\w/ ) {    # alphanumeric ..
                 $saw_alpha     = 1;
                 $id_scan_state = ':';           # now need ::
                 $identifier .= $tok;
@@ -5895,11 +5895,6 @@ sub scan_identifier_do {
                 #  howdy::123::bubba();
                 #
             }
-            elsif ( $tok =~ /^[0-9]/ ) {    # numeric
-                $saw_alpha     = 1;
-                $id_scan_state = ':';       # now need ::
-                $identifier .= $tok;
-            }
             elsif ( $tok eq '::' ) {
                 $id_scan_state = 'A';
                 $identifier .= $tok;
@@ -6053,7 +6048,7 @@ sub scan_identifier_do {
         }
         elsif ( $id_scan_state eq '&' ) {    # starting sub call?
 
-            if ( $tok =~ /^[\$A-Za-z_]/ ) {    # alphanumeric ..
+            if ( $tok =~ /^[\$\w]/ ) {    # alphanumeric ..
                 $id_scan_state = ':';          # now need ::
                 $saw_alpha     = 1;
                 $identifier .= $tok;
@@ -6063,11 +6058,6 @@ sub scan_identifier_do {
                 $saw_alpha     = 1;
                 $identifier .= $tok;
             }
-            elsif ( $tok =~ /^[0-9]/ ) {    # numeric..see comments above
-                $id_scan_state = ':';       # now need ::
-                $saw_alpha     = 1;
-                $identifier .= $tok;
-            }
             elsif ( $tok =~ /^\s*$/ ) {     # allow space
             }
             elsif ( $tok eq '::' ) {        # leading ::
@@ -6109,7 +6099,7 @@ sub scan_identifier_do {
         }
         elsif ( $id_scan_state eq 'A' ) {    # looking for alpha (after ::)
 
-            if ( $tok =~ /^[A-Za-z_]/ ) {    # found it
+            if ( $tok =~ /^\w/ ) {    # found it
                 $identifier .= $tok;
                 $id_scan_state = ':';        # now need ::
                 $saw_alpha     = 1;
@@ -6119,11 +6109,6 @@ sub scan_identifier_do {
                 $id_scan_state = ':';        # now need ::
                 $saw_alpha     = 1;
             }
-            elsif ( $tok =~ /^[0-9]/ ) {     # numeric..see comments above
-                $identifier .= $tok;
-                $id_scan_state = ':';        # now need ::
-                $saw_alpha     = 1;
-            }
             elsif ( ( $identifier =~ /^sub / ) && ( $tok =~ /^\s*$/ ) ) {
                 $id_scan_state = '(';
                 $identifier .= $tok;
@@ -6144,12 +6129,8 @@ sub scan_identifier_do {
                 $identifier .= $tok;
                 $id_scan_state = 'A';        # now require alpha
             }
-            elsif ( $tok =~ /^[A-Za-z_]/ ) {    # more alphanumeric is ok here
-                $identifier .= $tok;
-                $id_scan_state = ':';           # now need ::
-                $saw_alpha     = 1;
-            }
-            elsif ( $tok =~ /^[0-9]/ ) {        # numeric..see comments above
+            ##elsif ( $tok =~ /^[A-Za-z_]/ ) {    # more alphanumeric is ok here
+            elsif ( $tok =~ /^\w/ ) {    # more alphanumeric is ok here
                 $identifier .= $tok;
                 $id_scan_state = ':';           # now need ::
                 $saw_alpha     = 1;