From 75fb39e62289e93e4846d8d5c83542c1f16cc62c Mon Sep 17 00:00:00 2001 From: Steve Hancock Date: Sun, 6 Sep 2020 18:21:41 -0700 Subject: [PATCH] Added DESTROY subs to avoid AUTOLOAD calls in some versions of perl --- lib/Perl/Tidy.pm | 4 +++ lib/Perl/Tidy/Formatter.pm | 48 ++++++++++++++++---------------- lib/Perl/Tidy/HtmlWriter.pm | 4 +++ lib/Perl/Tidy/VerticalAligner.pm | 5 ++++ 4 files changed, 37 insertions(+), 24 deletions(-) diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index 7db691aa..8a995870 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -113,6 +113,10 @@ BEGIN { $VERSION = '20200907'; } +sub DESTROY { + # required to avoid call to AUTOLOAD in some versions of perl +} + sub AUTOLOAD { # Catch any undefined sub calls so that we are sure to get diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index a9037041..18713566 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -35,24 +35,6 @@ sub Exit { croak "unexpected return from Perl::Tidy::Exit"; } -sub AUTOLOAD { - - # Catch any undefined sub calls so that we are sure to get - # some diagnostic information. This sub should never be called - # except for a programming error. - our $AUTOLOAD; - my ( $pkg, $fname, $lno ) = caller(); - print STDERR <[_added_semicolon_count_]; } -sub DESTROY { - my $self = shift; - $self->_decrement_count(); - return; -} - sub get_output_line_number { my ($self) = @_; my $vao = $self->[_vertical_aligner_object_]; return $vao->get_output_line_number(); } +sub AUTOLOAD { + + # Catch any undefined sub calls so that we are sure to get + # some diagnostic information. This sub should never be called + # except for a programming error. + our $AUTOLOAD; + my ( $pkg, $fname, $lno ) = caller(); + print STDERR <_decrement_count(); + return; +} + sub new { my ( $class, @args ) = @_; diff --git a/lib/Perl/Tidy/HtmlWriter.pm b/lib/Perl/Tidy/HtmlWriter.pm index c175f7e0..cd682930 100644 --- a/lib/Perl/Tidy/HtmlWriter.pm +++ b/lib/Perl/Tidy/HtmlWriter.pm @@ -57,6 +57,10 @@ EOM "Error exit due to unexpected Autoload call to '$AUTOLOAD'\n"); } +sub DESTROY { + # required to avoid call to AUTOLOAD in some versions of perl +} + sub new { my ( $class, @args ) = @_; diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index 77d63abb..4d985eb7 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -48,6 +48,11 @@ EOM "Error exit due to unexpected Autoload call to '$AUTOLOAD'\n"); } +sub DESTROY { + # required to avoid call to AUTOLOAD in some versions of perl +} + + BEGIN { # Define the fixed indexes for variables in $self, which is an array -- 2.39.5