This is a detailed log of changes since the release 20200907. All bugs were found with the help of automated random testing.
In random testing, the -mangle option introduced a syntax error by deleting the space between barewords and quotes (test file 'MxScreen'), such as:
oops"Your login, $Bad_Login, is not valid";
Sub 'is_essential_whitespace' was updated to prevent this on 27 Sep 2020, in 'keep any space between a bareword and quote', f32553c.
The .LOG file reports any disagreements between the indentation of the input and output files. This can help locate brace errors. These were incorrect when some of the options were used, including --whitespace-cycle, -bbhb, -nib. This was corrected 24 Sep 2020, 'fixed incorrect log entry for indentation disagreement', 3d40545. At the same time, locations of closing brace indentation disagreements are now tracked and reported in the .ERR file when there is a brace error. This can help localize the error if the file was previously formatted by perltidy.
Previously only a complaint was given, which went into the log file and was not normally seen. Perl silently accepts this but it can cause significant problems with pod utilities, so a clear warning is better. This situation arose in testing on random files in combination with a -dp flag and it took some time to understand the results because of the lack of a warning.
This is not a bug, but is cleaner coding and insures that error messages get reported. This change was made 20 Sep 2020, 'switch from eval { } to ->can('finish_formatting')', 28f2a4f.
The following message was generated during automated testing
Use of uninitialized value $cti in numeric eq (==) at /home/steve/bin/Perl/Tidy/Formatter.pm line 12079.
Use of uninitialized value $cti in numeric eq (==) at /home/steve/bin/Perl/Tidy/Formatter.pm line 12089.
Use of uninitialized value $cti in numeric eq (==) at /home/steve/bin/Perl/Tidy/Formatter.pm line 12097.
The problem could be simplified to running perltidy -wn on this snippet:
__PACKAGE__->load_components( qw(
> Core
>
> ) );
This was fixed 20 Sep 2020 in 'fixed_uninitialized_value', 8d6c4ed.
The following snippet was being incorrecly parsed:
print <<
# Hello World 13!
;
print "DONE\n";
This is a deprecated here-doc without a specified target but currently still a valid program. It would have been correctly parsed if the semicolon followed the '<<' operator rather than the here-doc.
This was found in random testing and fixed 16 Sep 2020. A warning message about deprecated here-doc targets was added.
The -> can now be vertically aligned if a space is placed before it with -wls='->'. Added 15 Sep 2020 as part of previous item, 9ac6af6.
These flags give control over the opening token of a multiple-line list. They are described in the man pages, perltidy.html. Added 15 Sep 2020 in "added flags -bbhb=n, -bbsb=n, -bbq=n, suggestion git #38". 9ac6af6.
A change was made to allow a '=>' at the end of a line to align vertically, provided that it aligns with two or more other '=>' tokens. This update was 14 Sep 2020, 'Allow line-ending '=>' to align vertically', ea96739.
The following message was generated when running perltidy on random text:
Use of uninitialized value $K_semicolon in subtraction (-) at /home/steve/bin/Perl/Tidy/Formatter.pm line 16467.
This was fixed 14 Sep 2020, included in 'Allow line-ending '=>' to align vertically', ea96739.
A rule was added to prevent a file consisting of a single semicolon
;
from becoming a zero length file. This could cause problems with other software. Fixed 13 Sep 2020, 'do not create a zero length file by deleting semicolons', b39195e.
The following message was generated when running perltidy on random text:
Use of uninitialized value $cti in numeric eq (==) at /home/steve/bin/Perl/Tidy/Formatter.pm line 11926.
Use of uninitialized value $cti in numeric eq (==) at /home/steve/bin/Perl/Tidy/Formatter.pm line 11936.
Use of uninitialized value $cti in numeric eq (==) at /home/steve/bin/Perl/Tidy/Formatter.pm line 11944.
This was fixed 13 Sep 2020 in 'fixed unitialized variable problem ', adb2096.
The following message was generated when running perltidy on random text:
substr outside of string at /home/steve/bin/Perl/Tidy/Tokenizer.pm line 7362.
Use of uninitialized value in concatenation (.) or string at /home/steve/bin/Perl/Tidy/Tokenizer.pm line 7362.
This was fixed 13 Sep 2020 in 'fixed unitialized variable problem', 5bf49a3.
The following message was generated when running perltidy on random text:
Use of uninitialized value $K_opening in subtraction (-) at /home/steve/bin/Perl/Tidy/Formatter.pm line 16467.
This was fixed 13 Sep 2020 in 'fix undefined variable reference', 1919482.
The following snippet generated a warning that there might be a hash-bang after the start of the script.
$x = 2;
#! sunos does not yet provide a /usr/bin/perl
$script = "$^X $script";
To prevent this annoyance, the warning is not given unless the first nonblank character after the '#!' is a '/'. Note that this change is just for the warning message. The actual hash bang check does not require the slash.
Fixed 13 Sep 2020, 'prevent unnecessary hash-bang warning message' 4f7733e and 'improved hash-bang warning filter', fa84904.
An unitialized index was referenced when running on a file of randomly generated text:
Use of uninitialized value $K_oo in subtraction (-) at /home/steve/bin/Perl/Tidy/Formatter.pm line 7259.
This was fixed 12 Sep 2020 in 'fixed undefined index', 616bb88.
The parameter combination -lp -wc triggered an internal bug message from perltidy:
398: Program bug with -lp. seqno=77 should be 254 and i=1 should be less than max=-1
713: The logfile perltidy.LOG may contain useful information
713:
713: Oops, you seem to have encountered a bug in perltidy. Please check the
713: BUGS file at http://perltidy.sourceforge.net. If the problem is not
713: listed there, please report it so that it can be corrected. Include the
...
The problem is that the parameters --line-up-parentheses and --whitespace-cycle=n are not compatible. The fix is to write a message and turn off the -wc parameter when the both occur. This was fixed 8 Sep 2020 in "do not allow -wc and -lp together, can cause bugs", 7103781.
This snippet after processing with the indicated parameters triggered a Fault message in store-token-to-go due to discontinuous internal index values :
perltidy --noadd-newlines --space-terminal-semicolon
if ( $_ =~ /PENCIL/ ) { $pencil_flag= 1 } ; ;
$yy=1;
This triggered the message:
==============================================================================
While operating on input stream with name: '<stdin>'
A fault was detected at line 7472 of sub 'Perl::Tidy::Formatter::store_token_to_go'
in file '/home/steve/bin/Perl/Tidy/Formatter.pm'
which was called from line 8298 of sub 'Perl::Tidy::Formatter::process_line_of_CODE'
Message: 'Unexpected break in K values: 591 != 589+1'
This is probably an error introduced by a recent programming change.
==============================================================================
The deletion of the extra, spaced, comma had created an extra space in the token array which had not been forseen in the original programming. It was fixed 10 Sep 2020 in "fixed very rare fault found with automated testing", eb1b1d9.
This problem can be illustrated with this two-line snippet:
$#
eq$,?print"yes\n":print"no\n";
Perltidy joined '$#' and 'eq' to get $#eq, but should have stopped at the line end to get $# followed by keyword 'eq'. (Note that $# is deprecated). This was fixed 11 Sep 2020 in "fixed several fringe parsing bugs found in testing", 85e01b7.
This problem can be illustrated with the following test snippet which was not correctly parsed.
print$$ <300?"$$<300\n":$$<700?"$$<700\n":$$<2_000?"$$<2,000\n":$$<10_000?"$$ <10,000\n":"$$>9,999\n";
The problem is related to the '<' symbol following the '$$' variable, a possible filehandle, and is similar to a previous bug. The problem was corrected 11 Sep 2020 in "fixed several fringe parsing bugs found in testing", 85e01b7. The line now correctly formats to
print $$ < 300 ? "$$<300\n"
: $$ < 700 ? "$$<700\n"
: $$ < 2_000 ? "$$<2,000\n"
: $$ < 10_000 ? "$$ <10,000\n"
: "$$>9,999\n";
A file with incorrect bracing which effectively gave negative indentation caused a crash when a stack was referenced with a negative index. The problem was fixed 8 Sept 2020 in "convert array to hash to avoid trouble with neg levels in bad files", a720e0d.
This error can be demonstrated with this line.
print $i <10 ? "yes" : "no";
Perl has some strange parsing rules near a possible filehandle, and they change over time. The '<' here is a less than symbol, but perltidy expected that it might be the start of an angle operator, based on the old rules, and gave a warning. The formatting was still correct, but the warning was confusing. This has been fixed 8 Sep 2020 in 'remove confusing warning message', 0a4d725.
This problem is illustrated with the following snippet
$sth= $dbh->prepare (<<"END_OF_SELECT") or die "Couldn't prepare SQL" ;
SELECT COUNT(duration),SUM(duration)
FROM logins WHERE username='$user'
END_OF_SELECT
When run with a short line length it got broken after the here target, causing an error. This was due to a recent program change and fixed 7 Sep 2020 in 'fixed bug where long line with here target got broken', 8f7e4cb.
An uninitialized value was being referenced and triggered this message:
undefined test2, i_opening=5, max=18, caller=Perl::Tidy::Formatter ./perltidy-20200907.pl 13465
Use of uninitialized value $test2 in numeric eq (==) at ./perltidy-20200907.pl line 19692.
Fixed 8 Sep 2020 in 'fixed rare problem with stored index values for -lp option', 4147c8c.
This problem arose in several scripts involving the parameter --line-up-parentheses pluse one or more of the vertical tightness flags. It can be illustrated with the following snippet:
perltidy --line-up-parentheses --paren-vertical-tightness=1
if (
( $name, $chap ) =
$cur_fname =~ m!^Bible/
.*?/ # testament
.*?/ # range of books
(.*?)/ # book name
.*? # optional range of verses
(\d+)$!x
)
{
$cur_name = "$name $chap";
}
This gave
if (( $name, $chap ) =
.*?/ # testament
$cur_fname =~ m!^Bible/
.*?/ # range of books
(.*?)/ # book name
.*? # optional range of verses
(\d+)$!x
)
{
$cur_name = "$name $chap";
}
Notice the incorrect line order. The problem was an incorrect order of operations in the vertical aligner flush, leaving a line stranded and coming out in the wrong order. This was fixed 11 Sep 2020.
This crash was due to an index error which caused a non-existant object to be referenced. The problem is fixed 2020-09-07 in "fix problem of undefined values involving j_terminal_match", c5bfa77. The particular parameters which caused this were:
--noadd-newlines --nowant-left-space='='
This is not a bug but did take some time to resolve. The problem was reduced to the following script run with the -x flag (--look-for-hash-bang)
print(SCRIPT$headmaybe . <<EOB . <<'EOF' .$tailmaybe),$!;
#!$wd/perl
EOB
print "\$^X is $^X, \$0 is $0\n";
EOF
The resulting file had a syntax error (here-doc target EOB changed).
print(SCRIPT$headmaybe . <<EOB . <<'EOF' .$tailmaybe),$!;
#!$wd/perl
EOB print "\$^X is $^X, \$0 is $0\n";
EOF
The problem is that the -x flag tells perltidy not to start parsing until it sees a line starting with '#!', which happens to be in a here-doc in this case.
A warning was added to the manual 7 Sept 2020 in "add warning about inappropriate -x flag", fe66743.
This problem was reduced to the following snippet:
substr
(
$#
)
The deprecated variable '$#' was being parsed incorrectly, and this was due to an error in which the word 'substr' followed by a paren was taken as the start of a sub signature. The problem was fixed 8 Sep 2020 in 'fix problem parsing sub prototypes' 569e05f. The code
$container_type =~ /^sub/;
was corrected to be
$container_type =~ /^sub\b/;
Unitialized values were referenced. An index was not being tested. Fixed 8 Sep 2020 in "fix undefined variable", 9729965.
Use of uninitialized value $Kon in array element at /home/steve/bin/Perl/Tidy/Formatter.pm line 4022.
Use of uninitialized value $Kon in array element at /home/steve/bin/Perl/Tidy/Formatter.pm line 4023.
Use of uninitialized value $Ko in subtraction (-) at /home/steve/bin/Perl/Tidy/Formatter.pm line 4023.