From: Steve Hancock Date: Sun, 22 Mar 2020 14:43:13 +0000 (-0700) Subject: fix sub scan_identifier_do to use \w instead of [_A-Za-z] X-Git-Tag: 20200619~125 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=05d74f94b0554ef816c01612d687c767185dbea2;p=perltidy.git fix sub scan_identifier_do to use \w instead of [_A-Za-z] --- diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index a82aa9d8..43e1ec4d 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -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;