# Perltidy Change Log
-## 2023 07 01.04
+## 2023 09 09
- - Add parameters -wme, or --warn-missing-else, and -ame,
+ - Added new parameters -wme, or --warn-missing-else, and -ame,
or --add-missing else. The parameter -wme tells perltidy to issue
- a warning to the error output if an if-elsif-elsif-... chain does
- not end in an else block. The parameter -ame tells perltidy to
- insert an else block at the end of such a chain if there is none.
+ a warning if an if-elsif-... chain does not end in an else block.
+ The parameter -ame tells perltidy to insert an else block at the
+ end of such a chain if there is none.
For example, given the following snippet:
##FIXME - added with perltidy -ame
}
- The resulting code should be carefully reviewed, and the comment should
- be updated as appropriate. The comment can be changed with parameter
- -amec=s, where 's' is the comment in the else block. The man pages
- have more details.
+ The resulting code should be carefully reviewed, and the ##FIXME comment
+ should be updated as appropriate. The text of the ##FIXME comment can be
+ changed with parameter -amec=s, where 's' is the comment to mark the new
+ else block. The man pages have more details.
- The syntax of the parameter --use-feature=class, or -uf=class, which
new in the previous release, has been changed slightly for clarity.
- Issue git #122. Added parameter -lrt=n1:n2, or --line-range-tidy=n1:n2
to limit tidy operations to a limited line range. Line numbers start
- with 1. The man pages have details.
+ with 1. This parameter is mainly of interest to editing programs which
+ drive perltidy. The man pages have details.
- Some fairly rare instances of incorrect spacing have been fixed. The
problem was that the tokenizer being overly conservative in marking
- terms as possible filehandles. This cause the space after the possible
- filehandle to be frozen to its input value in order not to introduce
- an error in case Perl had to guess. The problem was fixed by having the
- tokenizer look ahead for operators which can eliminate the uncertainty.
- To illustrate, in the following line the term ``$d`` was previouly
- marked as a possible file handle, so no space was added after it.
+ terms as possible filehandles or indirect objects. This causes the space
+ after the possible filehandle to be frozen to its input value in order not
+ to introduce an error in case Perl had to guess. The problem was fixed
+ by having the tokenizer look ahead for operators which can eliminate the
+ uncertainty. To illustrate, in the following line the term ``$d`` was
+ previously marked as a possible filehandle, so no space was added after it.
print $d== 1 ? " [ON]\n" : $d ? " [$d]\n" : "\n";
+ ^
In the current version, the next token is seen to be an equality, so
``$d`` is marked as an ordinary identifier and normal spacing rules
can apply:
print $d == 1 ? " [ON]\n" : $d ? " [$d]\n" : "\n";
+ ^
- This version runs 7 to 10 percent faster than the previous release on
- large files, depending on options and file type.
+ large files, depending on options and file type. Much of the gain comes
+ from streamlined I/O operations.
+
+ - This version was stress-tested for many cpu hours with random
+ input parameters. No failures to converge, internal fault checks,
+ undefined variable references or other irregularities were seen.
+
## 2023 07 01
fits this definition of a list.
Note that a paren-less list of parameters is not a list by this definition, so
-these parameters have no effect on a peren-less list.
+these parameters have no effect on a paren-less list.
Another consequence is that if the only comma in a list is deleted, then it
cannot later be added back with these parameters because the container no
=head2 Missing Else Blocks
-One defensive programming technique is to require that every B<if-elsif->
-chain be terminated with an B<else> block, even though it is not required,
-to insure that there are no holes in the logic.
+A defensive programming technique is to require that every B<if-elsif-> chain
+be terminated with an B<else> block, even though it is not strictly required.
+This helps insure that there are no holes in the logic.
-For example, consider the following snippet:
+For example, consider the following snippet:
- if ( $level == 3 ) { $val = $global{'section'} }
- elsif ( $level == 2 ) { $val = $global{'chapter'} }
+ my $type = get_cards();
+ if ( $type = 1 ) { action("hold 'em") }
+ elsif ( $type = 2 ) { action("fold 'em") }
+ elsif ( $type = 3 ) { action("walk away") }
-What if the variable B<$level> is neither 2 nor 3? Maybe the original
-programmer knew that this was okay, but a new programmer might be unsure.
+What if the variable B<$type> is some other value? It might have been obvious
+that this was okay when the code was first written, but it might not be so
+clear when the code is reviewed a few years later. A terminal B<else> block
+with a comment would help clarify things.
-Perltidy has always written this information in its B<LOG> file (search for
-B<No else block>). But a problem is that you have to turn on the log file and
-look for it. The parameters in this section can either issue a warning if an
-B<else> is missing, or even insert an empty B<else> block where one is missing,
-or both.
+The parameters in this section can help by either issuing a warning if an
+B<else> is missing, or even inserting an empty B<else> block where one is
+missing, or both.
=over 4
=item B<-wme>, B<--warn-missing-else>
-This flag tells perltidy to issue a warning if a program is missing a terminal B<else> block. The default is not to issue such warnings.
+This flag tells perltidy to issue a warning if a program is missing a terminal B<else> block. The default is not to issue such a warning.
=item B<-ame>, B<--add-missing-else>
This flag tells perltidy to output an empty else block wherever a program is
-missing a terminal B<else> block. To get a warning when this is done you can
-also set B<-wme>. The default is not to add missing else blocks.
+missing a terminal B<else> block. To get a warning when this is done you
+should also set B<-wme>. The default is not to add missing else blocks.
=item B<-amec=s>, B<--add-missing-else-comment=s>
-This string is an optional side comment which will be placed within a new empty else block. The default is:
+This string is a side comment which will be written to highlight a
+new empty else block. The default is:
-amec='##FIXME - added with perltidy -ame'
=back
-For example, on the above example we get
+For example, on the above example we can add a missing else and also get
+a warning notice with:
# perltidy -ame -wme
- if ( $level == 3 ) { $val = $global{'section'} }
- elsif ( $level == 2 ) { $val = $global{'chapter'} }
+ my $type = get_cards();
+ if ( $type == 1 ) { action("hold 'em") }
+ elsif ( $type == 2 ) { action("fold 'em") }
+ elsif ( $type == 3 ) { action("walk away") }
else {
##FIXME - added with perltidy -ame
}
-Any B<##FIXME> comments should be changed appropriately after the code is
-inspected. For example, we might decide that it fine as is, and just leave
-a note for the next programmer:
+Any B<##FIXME> comments created in this way should be reviewed and changed
+appropriately. For example, one might decide that the code fine as is, and just
+change the comment to indicate that nothing has been overlooked:
- if ( $level == 3 ) { $val = $global{'section'} }
- elsif ( $level == 2 ) { $val = $global{'chapter'} }
+ my $type = get_cards();
+ if ( $type == 1 ) { action("hold 'em") }
+ elsif ( $type == 2 ) { action("fold 'em") }
+ elsif ( $type == 3 ) { action("walk away") }
else {
- # ok - other $level values can be safely ignored
+ # ok - no worries
}
-Or maybe it should never happen:
+Or maybe a deeper analysis reveals that something was missed:
- if ( $level == 3 ) { $val = $global{'section'} }
- elsif ( $level == 2 ) { $val = $global{'chapter'} }
- else {
- die("unexpected value of level=$level\n);
- }
+ my $type = get_cards();
+ if ( $type == 1 ) { action("hold 'em") }
+ elsif ( $type == 2 ) { action("fold 'em") }
+ elsif ( $type == 3 ) { action("walk away") }
+ else { action("run") }
-Note that this operation cannot be undone, so be careful to inspect the new
-code carefully.
+Sometimes it turns out that the else block should not reachable, in which case
+an error exit might be appropriate. In any case, having the B<else> block can
+improve code maintainability.
=head2 Retaining or Ignoring Existing Line Breaks
The following list shows all short parameter names which allow a prefix
'n' to produce the negated form:
- D anl asbl asc ast asu atc atnl aws b
- baa baao bar bbao bbb bbc bbs bl bli boa
- boc bok bol bom bos bot cblx ce conv cpb
- cs csc cscb cscw dac dbc dbs dcbl dcsc ddf
- dln dnl dop dp dpro drc dsc dsm dsn dtc
- dtt dwic dwls dwrs dws eos f fpva frm fs
- fso gcs hbc hbcm hbco hbh hbhh hbi hbj hbk
- hbm hbn hbp hbpd hbpu hbq hbs hbsc hbv hbw
- hent hic hicm hico hih hihh hii hij hik him
- hin hip hipd hipu hiq his hisc hiv hiw hsc
- html ibc icb icp iob ipc isbc iscl kgb kgbd
- kgbi kis lal log lop lp lsl mem nib ohbr
- okw ola olc oll olq opr opt osbc osbr otr
- ple pod pvl q sac sbc sbl scbb schb scp
- scsb sct se sfp sfs skp sob sobb sohb sop
- sosb sot ssc st sts t tac tbc toc tp
- tqw trp ts tsc tso vbc vc viu vmll vsc
- w wfc wn x xbt xci xlp xs
+ D ame anl asbl asc ast asu atc atnl aws
+ b baa baao bar bbao bbb bbc bbs bl bli
+ boa boc bok bol bom bos bot cblx ce conv
+ cpb cs csc cscb cscw dac dbc dbs dcbl dcsc
+ ddf dln dnl dop dp dpro drc dsc dsm dsn
+ dtc dtt dwic dwls dwrs dws eos f fpva frm
+ fs fso gcs hbc hbcm hbco hbh hbhh hbi hbj
+ hbk hbm hbn hbp hbpd hbpu hbq hbs hbsc hbv
+ hbw hent hic hicm hico hih hihh hii hij hik
+ him hin hip hipd hipu hiq his hisc hiv hiw
+ hsc html ibc icb icp iob ipc isbc iscl kgb
+ kgbd kgbi kis lal log lop lp lsl mem nib
+ ohbr okw ola olc oll olq opr opt osbc osbr
+ otr ple pod pvl q sac sbc sbl scbb schb
+ scp scsb sct se sfp sfs skp sob sobb sohb
+ sop sosb sot ssc st sts t tac tbc toc
+ tp tqw trp ts tsc tso vbc vc viu vmll
+ vsc w wfc wme wn x xbt xci xlp xs
Equivalently, the prefix 'no' or 'no-' on the corresponding long names may be
used.
=head1 VERSION
-This man page documents perltidy version 20230701.04
+This man page documents perltidy version 20230909
=head1 BUG REPORTS
<h1>Perltidy Change Log</h1>
-<h2>2023 07 01.04</h2>
+<h2>2023 09 09</h2>
-<pre><code>- Add parameters -wme, or --warn-missing-else, and -ame,
+<pre><code>- Added new parameters -wme, or --warn-missing-else, and -ame,
or --add-missing else. The parameter -wme tells perltidy to issue
- a warning to the error output if an if-elsif-elsif-... chain does
- not end in an else block. The parameter -ame tells perltidy to
- insert an else block at the end of such a chain if there is none.
+ a warning if an if-elsif-... chain does not end in an else block.
+ The parameter -ame tells perltidy to insert an else block at the
+ end of such a chain if there is none.
For example, given the following snippet:
##FIXME - added with perltidy -ame
}
- The resulting code should be carefully reviewed, and the comment should
- be updated as appropriate. The comment can be changed with parameter
- -amec=s, where 's' is the comment in the else block. The man pages
- have more details.
+ The resulting code should be carefully reviewed, and the ##FIXME comment
+ should be updated as appropriate. The text of the ##FIXME comment can be
+ changed with parameter -amec=s, where 's' is the comment to mark the new
+ else block. The man pages have more details.
- The syntax of the parameter --use-feature=class, or -uf=class, which
new in the previous release, has been changed slightly for clarity.
- Issue git #122. Added parameter -lrt=n1:n2, or --line-range-tidy=n1:n2
to limit tidy operations to a limited line range. Line numbers start
- with 1. The man pages have details.
+ with 1. This parameter is mainly of interest to editing programs which
+ drive perltidy. The man pages have details.
- Some fairly rare instances of incorrect spacing have been fixed. The
problem was that the tokenizer being overly conservative in marking
- terms as possible filehandles. This cause the space after the possible
- filehandle to be frozen to its input value in order not to introduce
- an error in case Perl had to guess. The problem was fixed by having the
- tokenizer look ahead for operators which can eliminate the uncertainty.
- To illustrate, in the following line the term ``$d`` was previouly
- marked as a possible file handle, so no space was added after it.
+ terms as possible filehandles or indirect objects. This causes the space
+ after the possible filehandle to be frozen to its input value in order not
+ to introduce an error in case Perl had to guess. The problem was fixed
+ by having the tokenizer look ahead for operators which can eliminate the
+ uncertainty. To illustrate, in the following line the term ``$d`` was
+ previously marked as a possible filehandle, so no space was added after it.
print $d== 1 ? " [ON]\n" : $d ? " [$d]\n" : "\n";
+ ^
In the current version, the next token is seen to be an equality, so
``$d`` is marked as an ordinary identifier and normal spacing rules
can apply:
print $d == 1 ? " [ON]\n" : $d ? " [$d]\n" : "\n";
+ ^
- This version runs 7 to 10 percent faster than the previous release on
- large files, depending on options and file type.
+ large files, depending on options and file type. Much of the gain comes
+ from streamlined I/O operations.
+
+- This version was stress-tested for many cpu hours with random
+ input parameters. No failures to converge, internal fault checks,
+ undefined variable references or other irregularities were seen.
</code></pre>
<h2>2023 07 01</h2>
<h1 id="VERSION">VERSION</h1>
-<p>This man page documents Perl::Tidy version 20230701.04</p>
+<p>This man page documents Perl::Tidy version 20230909</p>
<h1 id="LICENSE">LICENSE</h1>
<li><p>For the implementation of these parameters, a <b>list</b> is basically taken to be a container of items (parens, square brackets, or braces), which is not a code block, with one or more commas. These parameters only apply to something that fits this definition of a list.</p>
-<p>Note that a paren-less list of parameters is not a list by this definition, so these parameters have no effect on a peren-less list.</p>
+<p>Note that a paren-less list of parameters is not a list by this definition, so these parameters have no effect on a paren-less list.</p>
<p>Another consequence is that if the only comma in a list is deleted, then it cannot later be added back with these parameters because the container no longer fits this definition of a list. For example, given</p>
<h2 id="Missing-Else-Blocks">Missing Else Blocks</h2>
-<p>One defensive programming technique is to require that every <b>if-elsif-</b> chain be terminated with an <b>else</b> block, even though it is not required, to insure that there are no holes in the logic.</p>
+<p>A defensive programming technique is to require that every <b>if-elsif-</b> chain be terminated with an <b>else</b> block, even though it is not strictly required. This helps insure that there are no holes in the logic.</p>
<p>For example, consider the following snippet:</p>
-<pre><code> if ( $level == 3 ) { $val = $global{'section'} }
- elsif ( $level == 2 ) { $val = $global{'chapter'} }</code></pre>
+<pre><code> my $type = get_cards();
+ if ( $type = 1 ) { action("hold 'em") }
+ elsif ( $type = 2 ) { action("fold 'em") }
+ elsif ( $type = 3 ) { action("walk away") }</code></pre>
-<p>What if the variable <b>$level</b> is neither 2 nor 3? Maybe the original programmer knew that this was okay, but a new programmer might be unsure.</p>
+<p>What if the variable <b>$type</b> is some other value? It might have been obvious that this was okay when the code was first written, but it might not be so clear when the code is reviewed a few years later. A terminal <b>else</b> block with a comment would help clarify things.</p>
-<p>Perltidy has always written this information in its <b>LOG</b> file (search for <b>No else block</b>). But a problem is that you have to turn on the log file and look for it. The parameters in this section can either issue a warning if an <b>else</b> is missing, or even insert an empty <b>else</b> block where one is missing, or both.</p>
+<p>The parameters in this section can help by either issuing a warning if an <b>else</b> is missing, or even inserting an empty <b>else</b> block where one is missing, or both.</p>
<dl>
<dt id="wme---warn-missing-else"><b>-wme</b>, <b>--warn-missing-else</b></dt>
<dd>
-<p>This flag tells perltidy to issue a warning if a program is missing a terminal <b>else</b> block. The default is not to issue such warnings.</p>
+<p>This flag tells perltidy to issue a warning if a program is missing a terminal <b>else</b> block. The default is not to issue such a warning.</p>
</dd>
<dt id="ame---add-missing-else"><b>-ame</b>, <b>--add-missing-else</b></dt>
<dd>
-<p>This flag tells perltidy to output an empty else block wherever a program is missing a terminal <b>else</b> block. To get a warning when this is done you can also set <b>-wme</b>. The default is not to add missing else blocks.</p>
+<p>This flag tells perltidy to output an empty else block wherever a program is missing a terminal <b>else</b> block. To get a warning when this is done you should also set <b>-wme</b>. The default is not to add missing else blocks.</p>
</dd>
<dt id="amec-s---add-missing-else-comment-s"><b>-amec=s</b>, <b>--add-missing-else-comment=s</b></dt>
<dd>
-<p>This string is an optional side comment which will be placed within a new empty else block. The default is:</p>
+<p>This string is a side comment which will be written to highlight a new empty else block. The default is:</p>
<pre><code> -amec='##FIXME - added with perltidy -ame'</code></pre>
</dd>
</dl>
-<p>For example, on the above example we get</p>
+<p>For example, on the above example we can add a missing else and also get a warning notice with:</p>
<pre><code> # perltidy -ame -wme
- if ( $level == 3 ) { $val = $global{'section'} }
- elsif ( $level == 2 ) { $val = $global{'chapter'} }
+ my $type = get_cards();
+ if ( $type == 1 ) { action("hold 'em") }
+ elsif ( $type == 2 ) { action("fold 'em") }
+ elsif ( $type == 3 ) { action("walk away") }
else {
##FIXME - added with perltidy -ame
}</code></pre>
-<p>Any <b>##FIXME</b> comments should be changed appropriately after the code is inspected. For example, we might decide that it fine as is, and just leave a note for the next programmer:</p>
+<p>Any <b>##FIXME</b> comments created in this way should be reviewed and changed appropriately. For example, one might decide that the code fine as is, and just change the comment to indicate that nothing has been overlooked:</p>
-<pre><code> if ( $level == 3 ) { $val = $global{'section'} }
- elsif ( $level == 2 ) { $val = $global{'chapter'} }
+<pre><code> my $type = get_cards();
+ if ( $type == 1 ) { action("hold 'em") }
+ elsif ( $type == 2 ) { action("fold 'em") }
+ elsif ( $type == 3 ) { action("walk away") }
else {
- # ok - other $level values can be safely ignored
+ # ok - no worries
}</code></pre>
-<p>Or maybe it should never happen:</p>
+<p>Or maybe a deeper analysis reveals that something was missed:</p>
-<pre><code> if ( $level == 3 ) { $val = $global{'section'} }
- elsif ( $level == 2 ) { $val = $global{'chapter'} }
- else {
- die("unexpected value of level=$level\n);
- }</code></pre>
+<pre><code> my $type = get_cards();
+ if ( $type == 1 ) { action("hold 'em") }
+ elsif ( $type == 2 ) { action("fold 'em") }
+ elsif ( $type == 3 ) { action("walk away") }
+ else { action("run") }</code></pre>
-<p>Note that this operation cannot be undone, so be careful to inspect the new code carefully.</p>
+<p>Sometimes it turns out that the else block should not reachable, in which case an error exit might be appropriate. In any case, having the <b>else</b> block can improve code maintainability.</p>
<h2 id="Retaining-or-Ignoring-Existing-Line-Breaks">Retaining or Ignoring Existing Line Breaks</h2>
<p>The following list shows all short parameter names which allow a prefix 'n' to produce the negated form:</p>
-<pre><code> D anl asbl asc ast asu atc atnl aws b
- baa baao bar bbao bbb bbc bbs bl bli boa
- boc bok bol bom bos bot cblx ce conv cpb
- cs csc cscb cscw dac dbc dbs dcbl dcsc ddf
- dln dnl dop dp dpro drc dsc dsm dsn dtc
- dtt dwic dwls dwrs dws eos f fpva frm fs
- fso gcs hbc hbcm hbco hbh hbhh hbi hbj hbk
- hbm hbn hbp hbpd hbpu hbq hbs hbsc hbv hbw
- hent hic hicm hico hih hihh hii hij hik him
- hin hip hipd hipu hiq his hisc hiv hiw hsc
- html ibc icb icp iob ipc isbc iscl kgb kgbd
- kgbi kis lal log lop lp lsl mem nib ohbr
- okw ola olc oll olq opr opt osbc osbr otr
- ple pod pvl q sac sbc sbl scbb schb scp
- scsb sct se sfp sfs skp sob sobb sohb sop
- sosb sot ssc st sts t tac tbc toc tp
- tqw trp ts tsc tso vbc vc viu vmll vsc
- w wfc wn x xbt xci xlp xs</code></pre>
+<pre><code> D ame anl asbl asc ast asu atc atnl aws
+ b baa baao bar bbao bbb bbc bbs bl bli
+ boa boc bok bol bom bos bot cblx ce conv
+ cpb cs csc cscb cscw dac dbc dbs dcbl dcsc
+ ddf dln dnl dop dp dpro drc dsc dsm dsn
+ dtc dtt dwic dwls dwrs dws eos f fpva frm
+ fs fso gcs hbc hbcm hbco hbh hbhh hbi hbj
+ hbk hbm hbn hbp hbpd hbpu hbq hbs hbsc hbv
+ hbw hent hic hicm hico hih hihh hii hij hik
+ him hin hip hipd hipu hiq his hisc hiv hiw
+ hsc html ibc icb icp iob ipc isbc iscl kgb
+ kgbd kgbi kis lal log lop lp lsl mem nib
+ ohbr okw ola olc oll olq opr opt osbc osbr
+ otr ple pod pvl q sac sbc sbl scbb schb
+ scp scsb sct se sfp sfs skp sob sobb sohb
+ sop sosb sot ssc st sts t tac tbc toc
+ tp tqw trp ts tsc tso vbc vc viu vmll
+ vsc w wfc wme wn x xbt xci xlp xs</code></pre>
<p>Equivalently, the prefix 'no' or 'no-' on the corresponding long names may be used.</p>
<h1 id="VERSION">VERSION</h1>
-<p>This man page documents perltidy version 20230701.04</p>
+<p>This man page documents perltidy version 20230909</p>
<h1 id="BUG-REPORTS">BUG REPORTS</h1>
# then the Release version must be bumped, and it is probably past time for
# a release anyway.
- $VERSION = '20230701.04';
+ $VERSION = '20230909';
} ## end BEGIN
sub DESTROY {
=head1 VERSION
-This man page documents Perl::Tidy version 20230701.04
+This man page documents Perl::Tidy version 20230909
=head1 LICENSE
use strict;
use warnings;
use English qw( -no_match_vars );
-our $VERSION = '20230701.04';
+our $VERSION = '20230909';
use constant EMPTY_STRING => q{};
use constant SPACE => q{ };
use strict;
use warnings;
use English qw( -no_match_vars );
-our $VERSION = '20230701.04';
+our $VERSION = '20230909';
use constant EMPTY_STRING => q{};
package Perl::Tidy::FileWriter;
use strict;
use warnings;
-our $VERSION = '20230701.04';
+our $VERSION = '20230909';
use constant DEVEL_MODE => 0;
use constant EMPTY_STRING => q{};
use Carp;
use English qw( -no_match_vars );
use List::Util qw( min max first ); # min, max first are in Perl 5.8
-our $VERSION = '20230701.04';
+our $VERSION = '20230909';
# The Tokenizer will be loaded with the Formatter
##use Perl::Tidy::Tokenizer; # for is_keyword()
package Perl::Tidy::HtmlWriter;
use strict;
use warnings;
-our $VERSION = '20230701.04';
+our $VERSION = '20230909';
use English qw( -no_match_vars );
use File::Basename;
use strict;
use warnings;
use Carp;
-our $VERSION = '20230701.04';
+our $VERSION = '20230909';
use constant DEVEL_MODE => 0;
use constant EMPTY_STRING => q{};
use strict;
use warnings;
use Carp;
-our $VERSION = '20230701.04';
+our $VERSION = '20230909';
use constant DEVEL_MODE => 0;
package Perl::Tidy::IndentationItem;
use strict;
use warnings;
-our $VERSION = '20230701.04';
+our $VERSION = '20230909';
BEGIN {
package Perl::Tidy::Logger;
use strict;
use warnings;
-our $VERSION = '20230701.04';
+our $VERSION = '20230909';
use English qw( -no_match_vars );
use constant DEVEL_MODE => 0;
use warnings;
use English qw( -no_match_vars );
-our $VERSION = '20230701.04';
+our $VERSION = '20230909';
use Carp;
$code_skipping_pattern_begin,
$code_skipping_pattern_end,
$rOpts_code_skipping,
+ $rOpts_code_skipping_begin,
%is_END_DATA_format_sub,
%is_grep_alias,
%is_sub,
@{is_grep_alias}{@q} = (1) x scalar(@q);
}
- $rOpts_code_skipping = $rOpts->{'code-skipping'};
+ $rOpts_code_skipping = $rOpts->{'code-skipping'};
+ $rOpts_code_skipping_begin = $rOpts->{'code-skipping-begin'};
$code_skipping_pattern_begin =
make_code_skipping_pattern( $rOpts, 'code-skipping-begin', '#<<V' );
$code_skipping_pattern_end =
$input_line = EMPTY_STRING;
}
- $is_END_or_DATA = substr( $input_line, 0, 1 ) eq '_'
- && $input_line =~ /^__(END|DATA)__\s*$/;
}
- # Optimize for a full-line comment.
if ( !$in_quote ) {
+
+ # Optimize handling of a blank line
+ if ( !length($input_line) ) {
+ $line_of_tokens->{_line_type} = 'CODE';
+ $line_of_tokens->{_rtokens} = [];
+ $line_of_tokens->{_rtoken_type} = [];
+ $line_of_tokens->{_rlevels} = [];
+ $line_of_tokens->{_rci_levels} = [];
+ $line_of_tokens->{_rblock_type} = [];
+ $line_of_tokens->{_nesting_tokens_0} = $nesting_token_string;
+ $line_of_tokens->{_nesting_blocks_0} = $nesting_block_string;
+ return;
+ }
+
+ # Check comments
if ( substr( $input_line, 0, 1 ) eq '#' ) {
# and check for skipped section
- if ( $rOpts_code_skipping
- && $input_line =~ /$code_skipping_pattern_begin/ )
+ if (
+ (
+ substr( $input_line, 0, 4 ) eq '#<<V'
+ || $rOpts_code_skipping_begin
+ )
+ && $rOpts_code_skipping
+ && $input_line =~ /$code_skipping_pattern_begin/
+ )
{
$self->[_in_skipped_] = $self->[_last_line_number_];
return;
return;
}
- # Optimize handling of a blank line
- if ( !length($input_line) ) {
- $line_of_tokens->{_line_type} = 'CODE';
- $line_of_tokens->{_rtokens} = [];
- $line_of_tokens->{_rtoken_type} = [];
- $line_of_tokens->{_rlevels} = [];
- $line_of_tokens->{_rci_levels} = [];
- $line_of_tokens->{_rblock_type} = [];
- $line_of_tokens->{_nesting_tokens_0} = $nesting_token_string;
- $line_of_tokens->{_nesting_blocks_0} = $nesting_block_string;
- return;
+ # Look for __END__ or __DATA__ lines
+ if ( substr( $input_line, 0, 1 ) eq '_'
+ && $input_line =~ /^__(END|DATA)__\s*$/ )
+ {
+ $is_END_or_DATA = 1;
}
}
use warnings;
use Carp;
use English qw( -no_match_vars );
-our $VERSION = '20230701.04';
+our $VERSION = '20230909';
use Perl::Tidy::VerticalAligner::Alignment;
use Perl::Tidy::VerticalAligner::Line;
{ #<<< A non-indenting brace
-our $VERSION = '20230701.04';
+our $VERSION = '20230909';
sub new {
my ( $class, $rarg ) = @_;
use strict;
use warnings;
use English qw( -no_match_vars );
-our $VERSION = '20230701.04';
+our $VERSION = '20230909';
sub AUTOLOAD {