From: Steve Hancock Date: Thu, 7 Sep 2023 14:55:32 +0000 (-0700) Subject: update to v20230909 X-Git-Tag: 20230909^0 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=e9ea36535fccc4b16a9a20e0cab1d33415f9195d;p=perltidy.git update to v20230909 --- diff --git a/CHANGES.md b/CHANGES.md index 4f516031..f215aba0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,12 +1,12 @@ # 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: @@ -20,10 +20,10 @@ ##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. @@ -37,27 +37,36 @@ - 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 diff --git a/bin/perltidy b/bin/perltidy index 606e7d82..0ba47c79 100755 --- a/bin/perltidy +++ b/bin/perltidy @@ -3768,7 +3768,7 @@ block, with one or more commas. These parameters only apply to something that 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 @@ -3861,73 +3861,82 @@ commas are removed. =head2 Missing Else Blocks -One defensive programming technique is to require that every B -chain be terminated with an B 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 chain +be terminated with an B 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 block +with a comment would help clarify things. -Perltidy has always written this information in its B file (search for -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 is missing, or even insert an empty B block where one is missing, -or both. +The parameters in this section can help by either issuing a warning if an +B is missing, or even inserting an empty B 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 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 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 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 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 block can +improve code maintainability. =head2 Retaining or Ignoring Existing Line Breaks @@ -5753,24 +5762,24 @@ dot is added, and the backup file will be F . 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. @@ -5869,7 +5878,7 @@ The perltidy binary uses the Perl::Tidy module and is installed when that module =head1 VERSION -This man page documents perltidy version 20230701.04 +This man page documents perltidy version 20230909 =head1 BUG REPORTS diff --git a/docs/ChangeLog.html b/docs/ChangeLog.html index 2a2ecc57..890dde2e 100644 --- a/docs/ChangeLog.html +++ b/docs/ChangeLog.html @@ -1,12 +1,12 @@

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:
 
@@ -20,10 +20,10 @@
         ##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.
@@ -37,27 +37,35 @@
 
 - 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

diff --git a/docs/Tidy.html b/docs/Tidy.html index 3a2e9e9a..08176cfd 100644 --- a/docs/Tidy.html +++ b/docs/Tidy.html @@ -399,7 +399,7 @@

VERSION

-

This man page documents Perl::Tidy version 20230701.04

+

This man page documents Perl::Tidy version 20230909

LICENSE

diff --git a/docs/perltidy.html b/docs/perltidy.html index 1664dcec..a8529626 100644 --- a/docs/perltidy.html +++ b/docs/perltidy.html @@ -2990,7 +2990,7 @@
  • For the implementation of these parameters, a list 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.

    -

    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.

    +

    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.

    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

    @@ -3064,67 +3064,73 @@

    Missing Else Blocks

    -

    One defensive programming technique is to require that every if-elsif- chain be terminated with an 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 if-elsif- chain be terminated with an 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:

    -
        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 $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 $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 else block with a comment would help clarify things.

    -

    Perltidy has always written this information in its LOG file (search for 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 else is missing, or even insert an empty else block where one is missing, or both.

    +

    The parameters in this section can help by either issuing a warning if an else is missing, or even inserting an empty else block where one is missing, or both.

    -wme, --warn-missing-else
    -

    This flag tells perltidy to issue a warning if a program is missing a terminal 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 else block. The default is not to issue such a warning.

    -ame, --add-missing-else
    -

    This flag tells perltidy to output an empty else block wherever a program is missing a terminal else block. To get a warning when this is done you can also set -wme. The default is not to add missing else blocks.

    +

    This flag tells perltidy to output an empty else block wherever a program is missing a terminal else block. To get a warning when this is done you should also set -wme. The default is not to add missing else blocks.

    -amec=s, --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'
    -

    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 ##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 ##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 else block can improve code maintainability.

    Retaining or Ignoring Existing Line Breaks

    @@ -4496,24 +4502,24 @@

    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.

    @@ -4591,7 +4597,7 @@

    VERSION

    -

    This man page documents perltidy version 20230701.04

    +

    This man page documents perltidy version 20230909

    BUG REPORTS

    diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index f5a1fc67..c853fc7b 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -111,7 +111,7 @@ BEGIN { # 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 { diff --git a/lib/Perl/Tidy.pod b/lib/Perl/Tidy.pod index 65ad5014..d420dc8c 100644 --- a/lib/Perl/Tidy.pod +++ b/lib/Perl/Tidy.pod @@ -469,7 +469,7 @@ The module 'Perl::Tidy' comes with a binary 'perltidy' which is installed when t =head1 VERSION -This man page documents Perl::Tidy version 20230701.04 +This man page documents Perl::Tidy version 20230909 =head1 LICENSE diff --git a/lib/Perl/Tidy/Debugger.pm b/lib/Perl/Tidy/Debugger.pm index 8e1a3fe6..ffba2cec 100644 --- a/lib/Perl/Tidy/Debugger.pm +++ b/lib/Perl/Tidy/Debugger.pm @@ -8,7 +8,7 @@ package Perl::Tidy::Debugger; 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{ }; diff --git a/lib/Perl/Tidy/Diagnostics.pm b/lib/Perl/Tidy/Diagnostics.pm index 6a16e978..e1dbb90a 100644 --- a/lib/Perl/Tidy/Diagnostics.pm +++ b/lib/Perl/Tidy/Diagnostics.pm @@ -18,7 +18,7 @@ package Perl::Tidy::Diagnostics; use strict; use warnings; use English qw( -no_match_vars ); -our $VERSION = '20230701.04'; +our $VERSION = '20230909'; use constant EMPTY_STRING => q{}; diff --git a/lib/Perl/Tidy/FileWriter.pm b/lib/Perl/Tidy/FileWriter.pm index 0250311e..877ff0c7 100644 --- a/lib/Perl/Tidy/FileWriter.pm +++ b/lib/Perl/Tidy/FileWriter.pm @@ -7,7 +7,7 @@ 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{}; diff --git a/lib/Perl/Tidy/Formatter.pm b/lib/Perl/Tidy/Formatter.pm index e1d5907d..aeb77367 100644 --- a/lib/Perl/Tidy/Formatter.pm +++ b/lib/Perl/Tidy/Formatter.pm @@ -53,7 +53,7 @@ use constant SPACE => 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() diff --git a/lib/Perl/Tidy/HtmlWriter.pm b/lib/Perl/Tidy/HtmlWriter.pm index 157b670e..4ed4ead8 100644 --- a/lib/Perl/Tidy/HtmlWriter.pm +++ b/lib/Perl/Tidy/HtmlWriter.pm @@ -7,7 +7,7 @@ package Perl::Tidy::HtmlWriter; use strict; use warnings; -our $VERSION = '20230701.04'; +our $VERSION = '20230909'; use English qw( -no_match_vars ); use File::Basename; diff --git a/lib/Perl/Tidy/IOScalar.pm b/lib/Perl/Tidy/IOScalar.pm index 1c2a4147..f1d6cc85 100644 --- a/lib/Perl/Tidy/IOScalar.pm +++ b/lib/Perl/Tidy/IOScalar.pm @@ -10,7 +10,7 @@ package Perl::Tidy::IOScalar; use strict; use warnings; use Carp; -our $VERSION = '20230701.04'; +our $VERSION = '20230909'; use constant DEVEL_MODE => 0; use constant EMPTY_STRING => q{}; diff --git a/lib/Perl/Tidy/IOScalarArray.pm b/lib/Perl/Tidy/IOScalarArray.pm index 2c462886..be5531e6 100644 --- a/lib/Perl/Tidy/IOScalarArray.pm +++ b/lib/Perl/Tidy/IOScalarArray.pm @@ -14,7 +14,7 @@ package Perl::Tidy::IOScalarArray; use strict; use warnings; use Carp; -our $VERSION = '20230701.04'; +our $VERSION = '20230909'; use constant DEVEL_MODE => 0; diff --git a/lib/Perl/Tidy/IndentationItem.pm b/lib/Perl/Tidy/IndentationItem.pm index d444b5e2..a9a8b86a 100644 --- a/lib/Perl/Tidy/IndentationItem.pm +++ b/lib/Perl/Tidy/IndentationItem.pm @@ -8,7 +8,7 @@ package Perl::Tidy::IndentationItem; use strict; use warnings; -our $VERSION = '20230701.04'; +our $VERSION = '20230909'; BEGIN { diff --git a/lib/Perl/Tidy/Logger.pm b/lib/Perl/Tidy/Logger.pm index aa23eaa8..27ad2d72 100644 --- a/lib/Perl/Tidy/Logger.pm +++ b/lib/Perl/Tidy/Logger.pm @@ -8,7 +8,7 @@ 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; diff --git a/lib/Perl/Tidy/Tokenizer.pm b/lib/Perl/Tidy/Tokenizer.pm index a2c64c75..ea3b88b9 100644 --- a/lib/Perl/Tidy/Tokenizer.pm +++ b/lib/Perl/Tidy/Tokenizer.pm @@ -22,7 +22,7 @@ use strict; use warnings; use English qw( -no_match_vars ); -our $VERSION = '20230701.04'; +our $VERSION = '20230909'; use Carp; @@ -125,6 +125,7 @@ my ( $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, @@ -409,7 +410,8 @@ sub check_options { @{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', '#<{_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 '#<[_in_skipped_] = $self->[_last_line_number_]; return; @@ -5188,17 +5208,11 @@ EOM 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; } } diff --git a/lib/Perl/Tidy/VerticalAligner.pm b/lib/Perl/Tidy/VerticalAligner.pm index 3d676a0f..77385063 100644 --- a/lib/Perl/Tidy/VerticalAligner.pm +++ b/lib/Perl/Tidy/VerticalAligner.pm @@ -3,7 +3,7 @@ use strict; 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; diff --git a/lib/Perl/Tidy/VerticalAligner/Alignment.pm b/lib/Perl/Tidy/VerticalAligner/Alignment.pm index 7b8798a7..7b661415 100644 --- a/lib/Perl/Tidy/VerticalAligner/Alignment.pm +++ b/lib/Perl/Tidy/VerticalAligner/Alignment.pm @@ -10,7 +10,7 @@ use warnings; { #<<< A non-indenting brace -our $VERSION = '20230701.04'; +our $VERSION = '20230909'; sub new { my ( $class, $rarg ) = @_; diff --git a/lib/Perl/Tidy/VerticalAligner/Line.pm b/lib/Perl/Tidy/VerticalAligner/Line.pm index 97bca6b3..3452e353 100644 --- a/lib/Perl/Tidy/VerticalAligner/Line.pm +++ b/lib/Perl/Tidy/VerticalAligner/Line.pm @@ -10,7 +10,7 @@ package Perl::Tidy::VerticalAligner::Line; use strict; use warnings; use English qw( -no_match_vars ); -our $VERSION = '20230701.04'; +our $VERSION = '20230909'; sub AUTOLOAD {