From 00b8f0baa3a6642f52fff932050ca73744350059 Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Thu, 30 Mar 2023 16:41:42 -0700 Subject: [PATCH] fix c208, misparse of '$1x$2' This was found in some obfuscated perl code. --- dev-bin/run_tokenizer_tests.pl.data | 3 +++ lib/Perl/Tidy/Tokenizer.pm | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dev-bin/run_tokenizer_tests.pl.data b/dev-bin/run_tokenizer_tests.pl.data index 408ea2c4..0c6cb7b1 100644 --- a/dev-bin/run_tokenizer_tests.pl.data +++ b/dev-bin/run_tokenizer_tests.pl.data @@ -159,6 +159,9 @@ my $str = $$# the process ID . " xxx\n"; print "str='$str'\n"; +==> c208.in <== +$1x$2 + ==> git82.in <== say $ diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index 1a3a861f..0ca95c39 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -7893,9 +7893,11 @@ sub do_scan_package { } } elsif ( $tok =~ /^\w/ ) { # alphanumeric .. - $saw_alpha = 1; - $id_scan_state = $scan_state_COLON; # now need :: + $saw_alpha = 1; $identifier .= $tok; + + # now need :: except for special digit vars like '$1' (c208) + $id_scan_state = $tok =~ /^\d/ ? EMPTY_STRING : $scan_state_COLON; } elsif ( $tok eq '::' ) { $id_scan_state = $scan_state_ALPHA; -- 2.39.5