1Perltidy Change Log 2 2007 12 05 3 -Improved support for perl 5.10: New quote modifier 'p', new block type UNITCHECK, 4 new keyword break, improved formatting of given/when. 5 6 -Corrected tokenization bug of something like $var{-q}. 7 8 -Numerous minor formatting improvements. 9 10 -Corrected list of operators controlled by -baao -bbao to include 11 . : ? && || and or err xor 12 13 -Corrected very minor error in log file involving incorrect comment 14 regarding need for upper case of labels. 15 16 -Fixed problem where perltidy could run for a very long time 17 when given certain non-perl text files. 18 19 -Line breaks in un-parenthesized lists now try to follow 20 line breaks in the input file rather than trying to fill 21 lines. This usually works better, but if this causes 22 trouble you can use -iob to ignore any old line breaks. 23 Example for the following input snippet: 24 25 print 26 "conformability (Not the same dimension)\n", 27 "\t", $have, " is ", text_unit($hu), "\n", 28 "\t", $want, " is ", text_unit($wu), "\n", 29 ; 30 31 OLD: 32 print "conformability (Not the same dimension)\n", "\t", $have, " is ", 33 text_unit($hu), "\n", "\t", $want, " is ", text_unit($wu), "\n",; 34 35 NEW: 36 print "conformability (Not the same dimension)\n", 37 "\t", $have, " is ", text_unit($hu), "\n", 38 "\t", $want, " is ", text_unit($wu), "\n", 39 ; 40 41 2007 08 01 42 -Added -fpsc option (--fixed-position-side-comment). Thanks to Ueli Hugenschmidt. 43 For example -fpsc=40 tells perltidy to put side comments in column 40 44 if possible. 45 46 -Added -bbao and -baao options (--break-before-all-operators and 47 --break-after-all-operators) to simplify command lines and configuration 48 files. These define an initial preference for breaking at operators which can 49 be modified with -wba and -wbb flags. For example to break before all operators 50 except an = one could use --bbao -wba='=' rather than listing every 51 single perl operator (except =) on a -wbb flag. 52 53 -Added -kis option (--keep-interior-semicolons). Use the B<-kis> flag 54 to prevent breaking at a semicolon if there was no break there in the 55 input file. To illustrate, consider the following input lines: 56 57 dbmclose(%verb_delim); undef %verb_delim; 58 dbmclose(%expanded); undef %expanded; 59 dbmclose(%global); undef %global; 60 61 Normally these would be broken into six lines, but 62 perltidy -kis gives: 63 64 dbmclose(%verb_delim); undef %verb_delim; 65 dbmclose(%expanded); undef %expanded; 66 dbmclose(%global); undef %global; 67 68 -Improved formatting of complex ternary statements, with indentation 69 of nested statements. 70 OLD: 71 return defined( $cw->{Selected} ) 72 ? (wantarray) 73 ? @{ $cw->{Selected} } 74 : $cw->{Selected}[0] 75 : undef; 76 77 NEW: 78 return defined( $cw->{Selected} ) 79 ? (wantarray) 80 ? @{ $cw->{Selected} } 81 : $cw->{Selected}[0] 82 : undef; 83 84 -Text following un-parenthesized if/unless/while/until statements get a 85 full level of indentation. Suggested by Jeff Armstorng and others. 86 OLD: 87 return $ship->chargeWeapons("phaser-canon") 88 if $encounter->description eq 'klingon' 89 and $ship->firepower >= $encounter->firepower 90 and $location->status ne 'neutral'; 91 NEW: 92 return $ship->chargeWeapons("phaser-canon") 93 if $encounter->description eq 'klingon' 94 and $ship->firepower >= $encounter->firepower 95 and $location->status ne 'neutral'; 96 97 2007 05 08 98 -Fixed bug where #line directives were being indented. Thanks to 99 Philippe Bruhat. 100 101 2007 05 04 102 -Fixed problem where an extra blank line was added after an =cut when either 103 (a) the =cut started (not stopped) a POD section, or (b) -mbl > 1. 104 Thanks to J. Robert Ray and Bill Moseley. 105 106 2007 04 24 107 -ole (--output-line-ending) and -ple (--preserve-line-endings) should 108 now work on all systems rather than just unix systems. Thanks to Dan 109 Tyrell. 110 111 -Fixed problem of a warning issued for multiple subs for BEGIN subs 112 and other control subs. Thanks to Heiko Eissfeldt. 113 114 -Fixed problem where no space was introduced between a keyword or 115 bareword and a colon, such as: 116 117 ( ref($result) eq 'HASH' && !%$result ) ? undef: $result; 118 119 Thanks to Niek. 120 121 -Added a utility program 'break_long_quotes.pl' to the examples directory of 122 the distribution. It breaks long quoted strings into a chain of concatenated 123 sub strings no longer than a selected length. Suggested by Michael Renner as 124 a perltidy feature but was judged to be best done in a separate program. 125 126 -Updated docs to remove extra < and >= from list of tokens 127 after which breaks are made by default. Thanks to Bob Kleemann. 128 129 -Removed improper uses of $_ to avoid conflicts with external calls, giving 130 error message similar to: 131 Modification of a read-only value attempted at 132 /usr/share/perl5/Perl/Tidy.pm line 6907. 133 Thanks to Michael Renner. 134 135 -Fixed problem when errorfile was not a plain filename or filehandle 136 in a call to Tidy.pm. The call 137 perltidy(source => \$input, destination => \$output, errorfile => \$err); 138 gave the following error message: 139 Not a GLOB reference at /usr/share/perl5/Perl/Tidy.pm line 3827. 140 Thanks to Michael Renner and Phillipe Bruhat. 141 142 -Fixed problem where -sot would not stack an opening token followed by 143 a side comment. Thanks to Jens Schicke. 144 145 -improved breakpoints in complex math and other long statements. Example: 146 OLD: 147 return 148 log($n) + 0.577215664901532 + ( 1 / ( 2 * $n ) ) - 149 ( 1 / ( 12 * ( $n**2 ) ) ) + ( 1 / ( 120 * ( $n**4 ) ) ); 150 NEW: 151 return 152 log($n) + 0.577215664901532 + 153 ( 1 / ( 2 * $n ) ) - 154 ( 1 / ( 12 * ( $n**2 ) ) ) + 155 ( 1 / ( 120 * ( $n**4 ) ) ); 156 157 -more robust vertical alignment of complex terminal else blocks and ternary 158 statements. 159 160 2006 07 19 161 -Eliminated bug where a here-doc invoked through an 'e' modifier on a pattern 162 replacement text was not recognized. The tokenizer now recursively scans 163 replacement text (but does not reformat it). 164 165 -improved vertical alignment of terminal else blocks and ternary statements. 166 Thanks to Chris for the suggestion. 167 168 OLD: 169 if ( IsBitmap() ) { return GetBitmap(); } 170 elsif ( IsFiles() ) { return GetFiles(); } 171 else { return GetText(); } 172 173 NEW: 174 if ( IsBitmap() ) { return GetBitmap(); } 175 elsif ( IsFiles() ) { return GetFiles(); } 176 else { return GetText(); } 177 178 OLD: 179 $which_search = 180 $opts{"t"} ? 'title' 181 : $opts{"s"} ? 'subject' 182 : $opts{"a"} ? 'author' 183 : 'title'; 184 185 NEW: 186 $which_search = 187 $opts{"t"} ? 'title' 188 : $opts{"s"} ? 'subject' 189 : $opts{"a"} ? 'author' 190 : 'title'; 191 192 -improved indentation of try/catch blocks and other externally defined 193 functions accepting a block argument. Thanks to jae. 194 195 -Added support for Perl 5.10 features say and smartmatch. 196 197 -Added flag -pbp (--perl-best-practices) as an abbreviation for parameters 198 suggested in Damian Conway's "Perl Best Practices". -pbp is the same as: 199 200 -l=78 -i=4 -ci=4 -st -se -vt=2 -cti=0 -pt=1 -bt=1 -sbt=1 -bbt=1 -nsfs -nolq 201 -wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = 202 **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x=" 203 204 Please note that the -st here restricts input to standard input; use 205 -nst if necessary to override. 206 207 -Eliminated some needless breaks at equals signs in -lp indentation. 208 209 OLD: 210 $c = 211 Math::Complex->make(LEFT + $x * (RIGHT - LEFT) / SIZE, 212 TOP + $y * (BOTTOM - TOP) / SIZE); 213 NEW: 214 $c = Math::Complex->make(LEFT + $x * (RIGHT - LEFT) / SIZE, 215 TOP + $y * (BOTTOM - TOP) / SIZE); 216 217 A break at an equals is sometimes useful for preventing complex statements 218 from hitting the line length limit. The decision to do this was 219 over-eager in some cases and has been improved. Thanks to Royce Reece. 220 221 -qw quotes contained in braces, square brackets, and parens are being 222 treated more like those containers as far as stacking of tokens. Also 223 stack of closing tokens ending ');' will outdent to where the ');' would 224 have outdented if the closing stack is matched with a similar opening stack. 225 226 OLD: perltidy -soc -sct 227 __PACKAGE__->load_components( 228 qw( 229 PK::Auto 230 Core 231 ) 232 ); 233 NEW: perltidy -soc -sct 234 __PACKAGE__->load_components( qw( 235 PK::Auto 236 Core 237 ) ); 238 Thanks to Aran Deltac 239 240 -Eliminated some undesirable or marginally desirable vertical alignments. 241 These include terminal colons, opening braces, and equals, and particularly 242 when just two lines would be aligned. 243 244 OLD: 245 my $accurate_timestamps = $Stamps{lnk}; 246 my $has_link = 247 ... 248 NEW: 249 my $accurate_timestamps = $Stamps{lnk}; 250 my $has_link = 251 252 -Corrected a problem with -mangle in which a space would be removed 253 between a keyword and variable beginning with ::. 254 255 2006 06 14 256 -Attribute argument lists are now correctly treated as quoted strings 257 and not formatted. This is the most important update in this version. 258 Thanks to Borris Zentner, Greg Ferguson, Steve Kirkup. 259 260 -Updated to recognize the defined or operator, //, to be released in Perl 10. 261 Thanks to Sebastien Aperghis-Tramoni. 262 263 -A useful utility perltidyrc_dump.pl is included in the examples section. It 264 will read any perltidyrc file and write it back out in a standard format 265 (though comments are lost). 266 267 -Added option to have perltidy read and return a hash with the contents of a 268 perltidyrc file. This may be used by Leif Eriksen's tidyview code. This 269 feature is used by the demonstration program 'perltidyrc_dump.pl' in the 270 examples directory. 271 272 -Improved error checking in perltidyrc files. Unknown bare words were not 273 being caught. 274 275 -The --dump-options parameter now dumps parameters in the format required by a 276 perltidyrc file. 277 278 -V-Strings with underscores are now recognized. 279 For example: $v = v1.2_3; 280 281 -cti=3 option added which gives one extra indentation level to closing 282 tokens always. This provides more predictable closing token placement 283 than cti=2. If you are using cti=2 you might want to try cti=3. 284 285 -To identify all left-adjusted comments as static block comments, use C<-sbcp='^#'>. 286 287 -New parameters -fs, -fsb, -fse added to allow sections of code between #<<< 288 and #>>> to be passed through verbatim. This is enabled by default and turned 289 off by -nfs. Flags -fsb and -fse allow other beginning and ending markers. 290 Thanks to Wolfgang Werner and Marion Berryman for suggesting this. 291 292 -added flag -skp to put a space between all Perl keywords and following paren. 293 The default is to only do this for certain keywords. Suggested by 294 H.Merijn Brand. 295 296 -added flag -sfp to put a space between a function name and following paren. 297 The default is not to do this. Suggested by H.Merijn Brand. 298 299 -Added patch to avoid breaking GetOpt::Long::Configure set by calling program. 300 Thanks to Philippe Bruhat. 301 302 -An error was fixed in which certain parameters in a .perltidyrc file given 303 without the equals sign were not recognized. That is, 304 '--brace-tightness 0' gave an error but '--brace-tightness=0' worked 305 ok. Thanks to Zac Hansen. 306 307 -An error preventing the -nwrs flag from working was corrected. Thanks to 308 Greg Ferguson. 309 310 -Corrected some alignment problems with entab option. 311 312 -A bug with the combination of -lp and -extrude was fixed (though this 313 combination doesn't really make sense). The bug was that a line with 314 a single zero would be dropped. Thanks to Cameron Hayne. 315 316 -Updated Windows detection code to avoid an undefined variable. 317 Thanks to Joe Yates and Russ Jones. 318 319 -Improved formatting for short trailing statements following a closing paren. 320 Thanks to Joe Matarazzo. 321 322 -The handling of the -icb (indent closing block braces) flag has been changed 323 slightly to provide more consistent and predictable formatting of complex 324 structures. Instead of giving a closing block brace the indentation of the 325 previous line, it is now given one extra indentation level. The two methods 326 give the same result if the previous line was a complete statement, as in this 327 example: 328 329 if ($task) { 330 yyy(); 331 } # -icb 332 else { 333 zzz(); 334 } 335 The change also fixes a problem with empty blocks such as: 336 337 OLD, -icb: 338 elsif ($debug) { 339 } 340 341 NEW, -icb: 342 elsif ($debug) { 343 } 344 345 -A problem with -icb was fixed in which a closing brace was misplaced when 346 it followed a quote which spanned multiple lines. 347 348 -Some improved breakpoints for -wba='&& || and or' 349 350 -Fixed problem with misaligned cuddled else in complex statements 351 when the -bar flag was also used. Thanks to Alex and Royce Reese. 352 353 -Corrected documentation to show that --outdent-long-comments is the default. 354 Thanks to Mario Lia. 355 356 -New flag -otr (opening-token-right) is similar to -bar (braces-always-right) 357 but applies to non-structural opening tokens. 358 359 -new flags -sot (stack-opening-token), -sct (stack-closing-token). 360 Suggested by Tony. 361 362 2003 10 21 363 -The default has been changed to not do syntax checking with perl. 364 Use -syn if you want it. Perltidy is very robust now, and the -syn 365 flag now causes more problems than it's worth because of BEGIN blocks 366 (which get executed with perl -c). For example, perltidy will never 367 return when trying to beautify this code if -syn is used: 368 369 BEGIN { 1 while { }; } 370 371 Although this is an obvious error, perltidy is often run on untested 372 code which is more likely to have this sort of problem. A more subtle 373 example is: 374 375 BEGIN { use FindBin; } 376 377 which may hang on some systems using -syn if a shared file system is 378 unavailable. 379 380 -Changed style -gnu to use -cti=1 instead of -cti=2 (see next item). 381 In most cases it looks better. To recover the previous format, use 382 '-gnu -cti=2' 383 384 -Added flags -cti=n for finer control of closing token indentation. 385 -cti = 0 no extra indentation (default; same as -nicp) 386 -cti = 1 enough indentation so that the closing token 387 aligns with its opening token. 388 -cti = 2 one extra indentation level if the line has the form 389 ); ]; or }; (same as -icp). 390 391 The new option -cti=1 works well with -lp: 392 393 EXAMPLES: 394 395 # perltidy -lp -cti=1 396 @month_of_year = ( 397 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 398 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' 399 ); 400 401 # perltidy -lp -cti=2 402 @month_of_year = ( 403 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 404 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' 405 ); 406 This is backwards compatible with -icp. See revised manual for 407 details. Suggested by Mike Pennington. 408 409 -Added flag '--preserve-line-endings' or '-ple' to cause the output 410 line ending to be the same as in the input file, for unix, dos, 411 or mac line endings. Only works under unix. Suggested by 412 Rainer Hochschild. 413 414 -Added flag '--output-line-ending=s' or '-ole=s' where s=dos or win, 415 unix, or mac. Only works under unix. 416 417 -Files with Mac line endings should now be handled properly under unix 418 and dos without being passed through a converter. 419 420 -You may now include 'and', 'or', and 'xor' in the list following 421 '--want-break-after' to get line breaks after those keywords rather than 422 before them. Suggested by Rainer Hochschild. 423 424 -Corrected problem with command line option for -vtc=n and -vt=n. The 425 equals sign was being eaten up by the Windows shell so perltidy didn't 426 see it. 427 428 2003 07 26 429 -Corrected cause of warning message with recent versions of Perl: 430 "Possible precedence problem on bitwise & operator at ..." 431 Thanks to Jim Files. 432 433 -fixed bug with -html with '=for pod2html' sections, in which code/pod 434 output order was incorrect. Thanks to Tassilo von Parseval. 435 436 -fixed bug when the -html flag is used, in which the following error 437 message, plus others, appear: 438 did not see <body> in pod2html output 439 This was caused by a change in the format of html output by pod2html 440 VERSION 1.04 (included with perl 5.8). Thanks to Tassilo von Parseval. 441 442 -Fixed bug where an __END__ statement would be mistaken for a label 443 if it is immediately followed by a line with a leading colon. Thanks 444 to John Bayes. 445 446 -Implemented guessing logic for brace types when it is ambiguous. This 447 has been on the TODO list a long time. Thanks to Boris Zentner for 448 an example. 449 450 -Long options may now be negated either as '--nolong-option' 451 or '--no-long-option'. Thanks to Philip Newton for the suggestion. 452 453 -added flag --html-entities or -hent which controls the use of 454 Html::Entities for html formatting. Use --nohtml-entities or -nhent to 455 prevent the use of Html::Entities to encode special symbols. The 456 default is -hent. Html::Entities when formatting perl text to escape 457 special symbols. This may or may not be the right thing to do, 458 depending on browser/language combinations. Thanks to Burak Gursoy for 459 this suggestion. 460 461 -Bareword strings with leading '-', like, '-foo' now count as 1 token 462 for horizontal tightness. This way $a{'-foo'}, $a{foo}, and $a{-foo} 463 are now all treated similarly. Thus, by default, OLD: $a{ -foo } will 464 now be NEW: $a{-foo}. Suggested by Mark Olesen. 465 466 -added 2 new flags to control spaces between keywords and opening parens: 467 -sak=s or --space-after-keyword=s, and 468 -nsak=s or --nospace-after-keyword=s, where 's' is a list of keywords. 469 470 The new default list of keywords which get a space is: 471 472 "my local our and or eq ne if else elsif until unless while for foreach 473 return switch case given when" 474 475 Use -sak=s and -nsak=s to add and remove keywords from this list, 476 respectively. 477 478 Explanation: Stephen Hildrey noted that perltidy was being inconsistent 479 in placing spaces between keywords and opening parens, and sent a patch 480 to give user control over this. The above list was selected as being 481 a reasonable default keyword list. Previously, perltidy 482 had a hardwired list which also included these keywords: 483 484 push pop shift unshift join split die 485 486 but did not have 'our'. Example: if you prefer to make perltidy behave 487 exactly as before, you can include the following two lines in your 488 .perltidyrc file: 489 490 -sak="push pop local shift unshift join split die" 491 -nsak="our" 492 493 -Corrected html error in .toc file when -frm -html is used (extra "); 494 browsers were tolerant of it. 495 496 -Improved alignment of chains of binary and ?/: operators. Example: 497 OLD: 498 $leapyear = 499 $year % 4 ? 0 500 : $year % 100 ? 1 501 : $year % 400 ? 0 502 : 1; 503 NEW: 504 $leapyear = 505 $year % 4 ? 0 506 : $year % 100 ? 1 507 : $year % 400 ? 0 508 : 1; 509 510 -improved breakpoint choices involving '->' 511 512 -Corrected tokenization of things like ${#} or ${�}. For example, 513 ${�} is valid, but ${� } is a syntax error. 514 515 -Corrected minor tokenization errors with indirect object notation. 516 For example, 'new A::()' works now. 517 518 -Minor tokenization improvements; all perl code distributed with perl 5.8 519 seems to be parsed correctly except for one instance (lextest.t) 520 of the known bug. 521 522 2002 11 30 523 -Implemented scalar attributes. Thanks to Sean Tobin for noting this. 524 525 -Fixed glitch introduced in previous release where -pre option 526 was not outputting a leading html <pre> tag. 527 528 -Numerous minor improvements in vertical alignment, including the following: 529 530 -Improved alignment of opening braces in many cases. Needed for improved 531 switch/case formatting, and also suggested by Mark Olesen for sort/map/grep 532 formatting. For example: 533 534 OLD: 535 @modified = 536 map { $_->[0] } 537 sort { $a->[1] <=> $b->[1] } 538 map { [ $_, -M ] } @filenames; 539 540 NEW: 541 @modified = 542 map { $_->[0] } 543 sort { $a->[1] <=> $b->[1] } 544 map { [ $_, -M ] } @filenames; 545 546 -Eliminated alignments across unrelated statements. Example: 547 OLD: 548 $borrowerinfo->configure( -state => 'disabled' ); 549 $borrowerinfo->grid( -col => 1, -row => 0, -sticky => 'w' ); 550 551 NEW: 552 $borrowerinfo->configure( -state => 'disabled' ); 553 $borrowerinfo->grid( -col => 1, -row => 0, -sticky => 'w' ); 554 555 Thanks to Mark Olesen for suggesting this. 556 557 -Improved alignement of '='s in certain cases. 558 Thanks to Norbert Gruener for sending an example. 559 560 -Outdent-long-comments (-olc) has been re-instated as a default, since 561 it works much better now. Use -nolc if you want to prevent it. 562 563 -Added check for 'perltidy file.pl -o file.pl', which causes file.pl 564 to be lost. (The -b option should be used instead). Thanks to mreister 565 for reporting this problem. 566 567 2002 11 06 568 -Switch/case or given/when syntax is now recognized. Its vertical alignment 569 is not great yet, but it parses ok. The words 'switch', 'case', 'given', 570 and 'when' are now treated as keywords. If this causes trouble with older 571 code, we could introduce a switch to deactivate it. Thanks to Stan Brown 572 and Jochen Schneider for recommending this. 573 574 -Corrected error parsing sub attributes with call parameters. 575 Thanks to Marc Kerr for catching this. 576 577 -Sub prototypes no longer need to be on the same line as sub names. 578 579 -a new flag -frm or --frames will cause html output to be in a 580 frame, with table of contents in the left panel and formatted source 581 in the right panel. Try 'perltidy -html -frm somemodule.pm' for example. 582 583 -The new default for -html formatting is to pass the pod through Pod::Html. 584 The result is syntax colored code within your pod documents. This can be 585 deactivated with -npod. Thanks to those who have written to discuss this, 586 particularly Mark Olesen and Hugh Myers. 587 588 -the -olc (--outdent-long-comments) option works much better. It now outdents 589 groups of consecutive comments together, and by just the amount needed to 590 avoid having any one line exceeding the maximum line length. 591 592 -block comments are now trimmed of trailing whitespace. 593 594 -if a directory specified with -opath does not exist, it will be created. 595 596 -a table of contents to packages and subs is output when -html is used. 597 Use -ntoc to prevent this. 598 599 -fixed an unusual bug in which a 'for' statement following a 'format' 600 statement was not correctly tokenized. Thanks to Boris Zentner for 601 catching this. 602 603 -Tidy.pm is no longer dependent on modules IO::Scalar and IO::ScalarArray. 604 There were some speed issues. Suggested by Joerg Walter. 605 606 -The treatment of quoted wildcards (file globs) is now system-independent. 607 For example 608 609 perltidy 'b*x.p[lm]' 610 611 would match box.pl, box.pm, brinx.pm under any operating system. Of 612 course, anything unquoted will be subject to expansion by any shell. 613 614 -default color for keywords under -html changed from 615 SaddleBrown (#8B4513) to magenta4 (#8B008B). 616 617 -fixed an arg parsing glitch in which something like: 618 perltidy quick-help 619 would trigger the help message and exit, rather than operate on the 620 file 'quick-help'. 621 622 2002 09 22 623 -New option '-b' or '--backup-and-modify-in-place' will cause perltidy to 624 overwrite the original file with the tidied output file. The original 625 file will be saved with a '.bak' extension (which can be changed with 626 -bext=s). Thanks to Rudi Farkas for the suggestion. 627 628 -An index to all subs is included at the top of -html output, unless 629 only the <pre> section is written. 630 631 -Anchor lines of the form <a name="mysub"></a> are now inserted at key points 632 in html output, such as before sub definitions, for the convenience of 633 postprocessing scripts. Suggested by Howard Owen. 634 635 -The cuddled-else (-ce) flag now also makes cuddled continues, like 636 this: 637 638 while ( ( $pack, $file, $line ) = caller( $i++ ) ) { 639 # bla bla 640 } continue { 641 $prevpack = $pack; 642 } 643 644 Suggested by Simon Perreault. 645 646 -Fixed bug in which an extra blank line was added before an =head or 647 similar pod line after an __END__ or __DATA__ line each time 648 perltidy was run. Also, an extra blank was being added after 649 a terminal =cut. Thanks to Mike Birdsall for reporting this. 650 651 2002 08 26 652 -Fixed bug in which space was inserted in a hyphenated hash key: 653 my $val = $myhash{USER-NAME}; 654 was converted to: 655 my $val = $myhash{USER -NAME}; 656 Thanks to an anonymous bug reporter at sourceforge. 657 658 -Fixed problem with the '-io' ('--indent-only') where all lines 659 were double spaced. Thanks to Nick Andrew for reporting this bug. 660 661 -Fixed tokenization error in which something like '-e1' was 662 parsed as a number. 663 664 -Corrected a rare problem involving older perl versions, in which 665 a line break before a bareword caused problems with 'use strict'. 666 Thanks to Wolfgang Weisselberg for noting this. 667 668 -More syntax error checking added. 669 670 -Outdenting labels (-ola) has been made the default, in order to follow the 671 perlstyle guidelines better. It's probably a good idea in general, but 672 if you do not want this, use -nola in your .perltidyrc file. 673 674 -Updated rules for padding logical expressions to include more cases. 675 Thanks to Wolfgang Weisselberg for helpful discussions. 676 677 -Added new flag -osbc (--outdent-static-block-comments) which will 678 outdent static block comments by 2 spaces (or whatever -ci equals). 679 Requested by Jon Robison. 680 681 2002 04 25 682 -Corrected a bug, introduced in the previous release, in which some 683 closing side comments (-csc) could have incorrect text. This is 684 annoying but will be correct the next time perltidy is run with -csc. 685 686 -Implemented XHTML patch submitted by Ville Skytt�. 687 688 -Fixed bug where whitespace was being removed between 'Bar' and '()' 689 in a use statement like: 690 691 use Foo::Bar (); 692 693 Thanks to Ville Skytt� for reporting this. 694 695 -Whenever possible, if a logical expression is broken with leading 696 '&&', '||', 'and', or 'or', then the leading line will be padded 697 with additional space to produce alignment. This has been on the 698 todo list for a long time; thanks to Frank Steinhauer for reminding 699 me to do it. Notice the first line after the open parens here: 700 701 OLD: perltidy -lp 702 if ( 703 !param("rules.to.$linecount") 704 && !param("rules.from.$linecount") 705 && !param("rules.subject.$linecount") 706 && !( 707 param("rules.fieldname.$linecount") 708 && param("rules.fieldval.$linecount") 709 ) 710 && !param("rules.size.$linecount") 711 && !param("rules.custom.$linecount") 712 ) 713 714 NEW: perltidy -lp 715 if ( 716 !param("rules.to.$linecount") 717 && !param("rules.from.$linecount") 718 && !param("rules.subject.$linecount") 719 && !( 720 param("rules.fieldname.$linecount") 721 && param("rules.fieldval.$linecount") 722 ) 723 && !param("rules.size.$linecount") 724 && !param("rules.custom.$linecount") 725 ) 726 727 2002 04 16 728 -Corrected a mistokenization of variables for a package with a name 729 equal to a perl keyword. For example: 730 731 my::qx(); 732 package my; 733 sub qx{print "Hello from my::qx\n";} 734 735 In this case, the leading 'my' was mistokenized as a keyword, and a 736 space was being place between 'my' and '::'. This has been 737 corrected. Thanks to Martin Sluka for discovering this. 738 739 -A new flag -bol (--break-at-old-logic-breakpoints) 740 has been added to control whether containers with logical expressions 741 should be broken open. This is the default. 742 743 -A new flag -bok (--break-at-old-keyword-breakpoints) 744 has been added to follow breaks at old keywords which return lists, 745 such as sort and map. This is the default. 746 747 -A new flag -bot (--break-at-old-trinary-breakpoints) has been added to 748 follow breaks at trinary (conditional) operators. This is the default. 749 750 -A new flag -cab=n has been added to control breaks at commas after 751 '=>' tokens. The default is n=1, meaning break unless this breaks 752 open an existing on-line container. 753 754 -A new flag -boc has been added to allow existing list formatting 755 to be retained. (--break-at-old-comma-breakpoints). See updated manual. 756 757 -A new flag -iob (--ignore-old-breakpoints) has been added to 758 prevent the locations of old breakpoints from influencing the output 759 format. 760 761 -Corrected problem where nested parentheses were not getting full 762 indentation. This has been on the todo list for some time; thanks 763 to Axel Rose for a snippet demonstrating this issue. 764 765 OLD: inner list is not indented 766 $this->sendnumeric( 767 $this->server, 768 ( 769 $ret->name, $user->username, $user->host, 770 $user->server->name, $user->nick, "H" 771 ), 772 ); 773 774 NEW: 775 $this->sendnumeric( 776 $this->server, 777 ( 778 $ret->name, $user->username, $user->host, 779 $user->server->name, $user->nick, "H" 780 ), 781 ); 782 783 -Code cleaned up by removing the following unused, undocumented flags. 784 They should not be in any .perltidyrc files because they were just 785 experimental flags which were never documented. Most of them placed 786 artificial limits on spaces, and Wolfgang Weisselberg convinced me that 787 most of them they do more harm than good by causing unexpected results. 788 789 --maximum-continuation-indentation (-mci) 790 --maximum-whitespace-columns 791 --maximum-space-to-comment (-xsc) 792 --big-space-jump (-bsj) 793 794 -Pod file 'perltidy.pod' has been appended to the script 'perltidy', and 795 Tidy.pod has been append to the module 'Tidy.pm'. Older MakeMaker's 796 were having trouble. 797 798 -A new flag -isbc has been added for more control on comments. This flag 799 has the effect that if there is no leading space on the line, then the 800 comment will not be indented, and otherwise it may be. If both -ibc and 801 -isbc are set, then -isbc takes priority. Thanks to Frank Steinhauer 802 for suggesting this. 803 804 -A new document 'stylekey.pod' has been created to quickly guide new users 805 through the maze of perltidy style parameters. An html version is 806 on the perltidy web page. Take a look! It should be very helpful. 807 808 -Parameters for controlling 'vertical tightness' have been added: 809 -vt and -vtc are the main controls, but finer control is provided 810 with -pvt, -pcvt, -bvt, -bcvt, -sbvt, -sbcvt. Block brace vertical 811 tightness controls have also been added. 812 See updated manual and also see 'stylekey.pod'. Simple examples: 813 814 # perltidy -lp -vt=1 -vtc=1 815 @month_of_year = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 816 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ); 817 818 # perltidy -lp -vt=1 -vtc=0 819 @month_of_year = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 820 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' 821 ); 822 823 -Lists which do not format well in uniform columns are now better 824 identified and formated. 825 826 OLD: 827 return $c->create( 'polygon', $x, $y, $x + $ruler_info{'size'}, 828 $y + $ruler_info{'size'}, $x - $ruler_info{'size'}, 829 $y + $ruler_info{'size'} ); 830 831 NEW: 832 return $c->create( 833 'polygon', $x, $y, 834 $x + $ruler_info{'size'}, 835 $y + $ruler_info{'size'}, 836 $x - $ruler_info{'size'}, 837 $y + $ruler_info{'size'} 838 ); 839 840 OLD: 841 radlablist($f1, pad('Initial', $p), $b->{Init}->get_panel_ref, 'None ', 842 'None', 'Default', 'Default', 'Simple', 'Simple'); 843 NEW: 844 radlablist($f1, 845 pad('Initial', $p), 846 $b->{Init}->get_panel_ref, 847 'None ', 'None', 'Default', 'Default', 'Simple', 'Simple'); 848 849 -Corrected problem where an incorrect html filename was generated for 850 external calls to Tidy.pm module. Fixed incorrect html title when 851 Tidy.pm is called with IO::Scalar or IO::Array source. 852 853 -Output file permissons are now set as follows. An output script file 854 gets the same permission as the input file, except that owner 855 read/write permission is added (otherwise, perltidy could not be 856 rerun). Html output files use system defaults. Previously chmod 0755 857 was used in all cases. Thanks to Mark Olesen for bringing this up. 858 859 -Missing semicolons will not be added in multi-line blocks of type 860 sort, map, or grep. This brings perltidy into closer agreement 861 with common practice. Of course, you can still put semicolons 862 there if you like. Thanks to Simon Perreault for a discussion of this. 863 864 -Most instances of extra semicolons are now deleted. This is 865 particularly important if the -csc option is used. Thanks to Wolfgang 866 Weisselberg for noting this. For example, the following line 867 (produced by 'h2xs' :) has an extra semicolon which will now be 868 removed: 869 870 BEGIN { plan tests => 1 }; 871 872 -New parameter -csce (--closing-side-comment-else-flag) can be used 873 to control what text is appended to 'else' and 'elsif' blocks. 874 Default is to just add leading 'if' text to an 'else'. See manual. 875 876 -The -csc option now labels 'else' blocks with additinal information 877 from the opening if statement and elsif statements, if space. 878 Thanks to Wolfgang Weisselberg for suggesting this. 879 880 -The -csc option will now remove any old closing side comments 881 below the line interval threshold. Thanks to Wolfgang Weisselberg for 882 suggesting this. 883 884 -The abbreviation feature, which was broken in the previous version, 885 is now fixed. Thanks to Michael Cartmell for noting this. 886 887 -Vertical alignment is now done for '||=' .. somehow this was 888 overlooked. 889 890 2002 02 25 891 -This version uses modules for the first time, and a standard perl 892 Makefile.PL has been supplied. However, perltidy may still be 893 installed as a single script, without modules. See INSTALL for 894 details. 895 896 -The man page 'perl2web' has been merged back into the main 'perltidy' 897 man page to simplify installation. So you may remove that man page 898 if you have an older installation. 899 900 -Added patch from Axel Rose for MacPerl. The patch prompts the user 901 for command line arguments before calling the module 902 Perl::Tidy::perltidy. 903 904 -Corrected bug with '-bar' which was introduced in the previous 905 version. A closing block brace was being indented. Thanks to 906 Alexandros M Manoussakis for reporting this. 907 908 -New parameter '--entab-leading-whitespace=n', or '-et=n', has been 909 added for those who prefer tabs. This behaves different from the 910 existing '-t' parameter; see updated man page. Suggested by Mark 911 Olesen. 912 913 -New parameter '--perl-syntax-check-flags=s' or '-pcsf=s' can be 914 used to change the flags passed to perltidy in a syntax check. 915 See updated man page. Suggested by Mark Olesen. 916 917 -New parameter '--output-path=s' or '-opath=s' will cause output 918 files to be placed in directory s. See updated man page. Thanks for 919 Mark Olesen for suggesting this. 920 921 -New parameter --dump-profile (or -dpro) will dump to 922 standard output information about the search for a 923 configuration file, the name of whatever configuration file 924 is selected, and its contents. This should help debugging 925 config files, especially on different Windows systems. 926 927 -The -w parameter now notes possible errors of the form: 928 929 $comment = s/^\s*(\S+)\..*/$1/; # trim whitespace 930 931 -Corrections added for a leading ':' and for leaving a leading 'tcsh' 932 line untouched. Mark Olesen reported that lines of this form were 933 accepted by perl but not by perltidy: 934 935 : # use -*- perl -*- 936 eval 'exec perl -wS $0 "$@"' # shell should exec 'perl' 937 unless 1; # but Perl should skip this one 938 939 Perl will silently swallow a leading colon on line 1 of a 940 script, and now perltidy will do likewise. For example, 941 this is a valid script, provided that it is the first line, 942 but not otherwise: 943 944 : print "Hello World\n"; 945 946 Also, perltidy will now mark a first line with leading ':' followed by 947 '#' as type SYSTEM (just as a #! line), not to be formatted. 948 949 -List formatting improved for certain lists with special 950 initial terms, such as occur with 'printf', 'sprintf', 951 'push', 'pack', 'join', 'chmod'. The special initial term is 952 now placed on a line by itself. For example, perltidy -gnu 953 954 OLD: 955 $Addr = pack( 956 "C4", hex($SourceAddr[0]), 957 hex($SourceAddr[1]), hex($SourceAddr[2]), 958 hex($SourceAddr[3]) 959 ); 960 961 NEW: 962 $Addr = pack("C4", 963 hex($SourceAddr[0]), hex($SourceAddr[1]), 964 hex($SourceAddr[2]), hex($SourceAddr[3])); 965 966 OLD: 967 push ( 968 @{$$self{states}}, '64', '66', '68', 969 '70', '72', '74', '76', 970 '78', '80', '82', '84', 971 '86', '88', '90', '92', 972 '94', '96', '98', '100', 973 '102', '104' 974 ); 975 976 NEW: 977 push ( 978 @{$$self{states}}, 979 '64', '66', '68', '70', '72', '74', '76', 980 '78', '80', '82', '84', '86', '88', '90', 981 '92', '94', '96', '98', '100', '102', '104' 982 ); 983 984 -Lists of complex items, such as matricies, are now detected 985 and displayed with just one item per row: 986 987 OLD: 988 $this->{'CURRENT'}{'gfx'}{'MatrixSkew'} = Text::PDF::API::Matrix->new( 989 [ 1, tan( deg2rad($a) ), 0 ], [ tan( deg2rad($b) ), 1, 0 ], 990 [ 0, 0, 1 ] 991 ); 992 993 NEW: 994 $this->{'CURRENT'}{'gfx'}{'MatrixSkew'} = Text::PDF::API::Matrix->new( 995 [ 1, tan( deg2rad($a) ), 0 ], 996 [ tan( deg2rad($b) ), 1, 0 ], 997 [ 0, 0, 1 ] 998 ); 999 1000 -The perl syntax check will be turned off for now when input is from 1001 standard input or standard output. The reason is that this requires 1002 temporary files, which has produced far too many problems during 1003 Windows testing. For example, the POSIX module under Windows XP/2000 1004 creates temporary names in the root directory, to which only the 1005 administrator should have permission to write. 1006 1007 -Merged patch sent by Yves Orton to handle appropriate 1008 configuration file locations for different Windows varieties 1009 (2000, NT, Me, XP, 95, 98). 1010 1011 -Added patch to properly handle a for/foreach loop without 1012 parens around a list represented as a qw. I didn't know this 1013 was possible until Wolfgang Weisselberg pointed it out: 1014 1015 foreach my $key qw\Uno Due Tres Quadro\ { 1016 print "Set $key\n"; 1017 } 1018 1019 But Perl will give a syntax error without the $ variable; ie this will 1020 not work: 1021 1022 foreach qw\Uno Due Tres Quadro\ { 1023 print "Set $_\n"; 1024 } 1025 1026 -Merged Windows version detection code sent by Yves Orton. Perltidy 1027 now automatically turns off syntax checking for Win 9x/ME versions, 1028 and this has solved a lot of robustness problems. These systems 1029 cannot reliably handle backtick operators. See man page for 1030 details. 1031 1032 -Merged VMS filename handling patch sent by Michael Cartmell. (Invalid 1033 output filenames were being created in some cases). 1034 1035 -Numerous minor improvements have been made for -lp style indentation. 1036 1037 -Long C-style 'for' expressions will be broken after each ';'. 1038 1039 'perltidy -gnu' gives: 1040 1041 OLD: 1042 for ($status = $db->seq($key, $value, R_CURSOR()) ; $status == 0 1043 and $key eq $origkey ; $status = $db->seq($key, $value, R_NEXT())) 1044 1045 NEW: 1046 for ($status = $db->seq($key, $value, R_CURSOR()) ; 1047 $status == 0 and $key eq $origkey ; 1048 $status = $db->seq($key, $value, R_NEXT())) 1049 1050 -For the -lp option, a single long term within parens 1051 (without commas) now has better alignment. For example, 1052 perltidy -gnu 1053 1054 OLD: 1055 $self->throw("Must specify a known host, not $location," 1056 . " possible values (" 1057 . join (",", sort keys %hosts) . ")"); 1058 1059 NEW: 1060 $self->throw("Must specify a known host, not $location," 1061 . " possible values (" 1062 . join (",", sort keys %hosts) . ")"); 1063 1064 2001 12 31 1065 -This version is about 20 percent faster than the previous 1066 version as a result of optimization work. The largest gain 1067 came from switching to a dispatch hash table in the 1068 tokenizer. 1069 1070 -perltidy -html will check to see if HTML::Entities is 1071 installed, and if so, it will use it to encode unsafe 1072 characters. 1073 1074 -Added flag -oext=ext to change the output file extension to 1075 be different from the default ('tdy' or 'html'). For 1076 example: 1077 1078 perltidy -html -oext=htm filename 1079 1080 will produce filename.htm 1081 1082 -Added flag -cscw to issue warnings if a closing side comment would replace 1083 an existing, different side comments. See the man page for details. 1084 Thanks to Peter Masiar for helpful discussions. 1085 1086 -Corrected tokenization error of signed hex/octal/binary numbers. For 1087 example, the first hex number below would have been parsed correctly 1088 but the second one was not: 1089 if ( ( $tmp >= 0x80_00_00 ) || ( $tmp < -0x80_00_00 ) ) { } 1090 1091 -'**=' was incorrectly tokenized as '**' and '='. This only 1092 caused a problem with the -extrude opton. 1093 1094 -Corrected a divide by zero when -extrude option is used 1095 1096 -The flag -w will now contain all errors reported by 'perl -c' on the 1097 input file, but otherwise they are not reported. The reason is that 1098 perl will report lots of problems and syntax errors which are not of 1099 interest when only a small snippet is being formatted (such as missing 1100 modules and unknown bare words). Perltidy will always report all 1101 significant syntax errors that it finds, such as unbalanced braces, 1102 unless the -q (quiet) flag is set. 1103 1104 -Merged modifications created by Hugh Myers into perltidy. 1105 These include a 'streamhandle' routine which allows perltidy 1106 as a module to operate on input and output arrays and strings 1107 in addition to files. Documentation and new packaging as a 1108 module should be ready early next year; This is an elegant, 1109 powerful update; many thanks to Hugh for contributing it. 1110 1111 2001 11 28 1112 -added a tentative patch which tries to keep any existing breakpoints 1113 at lines with leading keywords map,sort,eval,grep. The idea is to 1114 improve formatting of sequences of list operations, as in a schwartzian 1115 transform. Example: 1116 1117 INPUT: 1118 my @sorted = map { $_->[0] } 1119 sort { $a->[1] <=> $b->[1] } 1120 map { [ $_, rand ] } @list; 1121 1122 OLD: 1123 my @sorted = 1124 map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, rand ] } @list; 1125 1126 NEW: 1127 my @sorted = map { $_->[0] } 1128 sort { $a->[1] <=> $b->[1] } 1129 map { [ $_, rand ] } @list; 1130 1131 The new alignment is not as nice as the input, but this is an improvement. 1132 Thanks to Yves Orton for this suggestion. 1133 1134 -modified indentation logic so that a line with leading opening paren, 1135 brace, or square bracket will never have less indentation than the 1136 line with the corresponding opening token. Here's a simple example: 1137 1138 OLD: 1139 $mw->Button( 1140 -text => "New Document", 1141 -command => \&new_document 1142 )->pack( 1143 -side => 'bottom', 1144 -anchor => 'e' 1145 ); 1146 1147 Note how the closing ');' is lined up with the first line, even 1148 though it closes a paren in the 'pack' line. That seems wrong. 1149 1150 NEW: 1151 $mw->Button( 1152 -text => "New Document", 1153 -command => \&new_document 1154 )->pack( 1155 -side => 'bottom', 1156 -anchor => 'e' 1157 ); 1158 1159 This seems nicer: you can up-arrow with an editor and arrive at the 1160 opening 'pack' line. 1161 1162 -corrected minor glitch in which cuddled else (-ce) did not get applied 1163 to an 'unless' block, which should look like this: 1164 1165 unless ($test) { 1166 1167 } else { 1168 1169 } 1170 1171 Thanks to Jeremy Mates for reporting this. 1172 1173 -The man page has been reorganized to parameters easier to find. 1174 1175 -Added check for multiple definitions of same subroutine. It is easy 1176 to introduce this problem when cutting and pasting. Perl does not 1177 complain about it, but it can lead to disaster. 1178 1179 -The command -pro=filename or -profile=filename may be used to specify a 1180 configuration file which will override the default name of .perltidyrc. 1181 There must not be a space on either side of the '=' sign. I needed 1182 this to be able to easily test perltidy with a variety of different 1183 configuration files. 1184 1185 -Side comment alignment has been improved somewhat across frequent level 1186 changes, as in short if/else blocks. Thanks to Wolfgang Weisselberg 1187 for pointing out this problem. For example: 1188 1189 OLD: 1190 if ( ref $self ) { # Called as a method 1191 $format = shift; 1192 } 1193 else { # Regular procedure call 1194 $format = $self; 1195 undef $self; 1196 } 1197 1198 NEW: 1199 if ( ref $self ) { # Called as a method 1200 $format = shift; 1201 } 1202 else { # Regular procedure call 1203 $format = $self; 1204 undef $self; 1205 } 1206 1207 -New command -ssc (--static-side-comment) and related command allows 1208 side comments to be spaced close to preceding character. This is 1209 useful for displaying commented code as side comments. 1210 1211 -New command -csc (--closing-side-comment) and several related 1212 commands allow comments to be added to (and deleted from) any or all 1213 closing block braces. This can be useful if you have to maintain large 1214 programs, especially those that you didn't write. See updated man page. 1215 Thanks to Peter Masiar for this suggestion. For a simple example: 1216 1217 perltidy -csc 1218 1219 sub foo { 1220 if ( !defined( $_[0] ) ) { 1221 print("Hello, World\n"); 1222 } 1223 else { 1224 print( $_[0], "\n" ); 1225 } 1226 } ## end sub foo 1227 1228 This added '## end sub foo' to the closing brace. 1229 To remove it, perltidy -ncsc. 1230 1231 -New commands -ola, for outdenting labels, and -okw, for outdenting 1232 selected control keywords, were implemented. See the perltidy man 1233 page for details. Thanks to Peter Masiar for this suggestion. 1234 1235 -Hanging side comment change: a comment will not be considered to be a 1236 hanging side comment if there is no leading whitespace on the line. 1237 This should improve the reliability of identifying hanging side comments. 1238 Thanks to Peter Masiar for this suggestion. 1239 1240 -Two new commands for outdenting, -olq (outdent-long-quotes) and -olc 1241 (outdent-long-comments), have been added. The original -oll 1242 (outdent-long-lines) remains, and now is an abbreviation for -olq and -olc. 1243 The new default is just -olq. This was necessary to avoid inconsistency with 1244 the new static block comment option. 1245 1246 -Static block comments: to provide a way to display commented code 1247 better, the convention is used that comments with a leading '##' should 1248 not be formatted as usual. Please see '-sbc' (or '--static-block-comment') 1249 for documentation. It can be deactivated with with -nsbc, but 1250 should not normally be necessary. Thanks to Peter Masiar for this 1251 suggestion. 1252 1253 -Two changes were made to help show structure of complex lists: 1254 (1) breakpoints are forced after every ',' in a list where any of 1255 the list items spans multiple lines, and 1256 (2) List items which span multiple lines now get continuation indentation. 1257 1258 The following example illustrates both of these points. Many thanks to 1259 Wolfgang Weisselberg for this snippet and a discussion of it; this is a 1260 significant formatting improvement. Note how it is easier to see the call 1261 parameters in the NEW version: 1262 1263 OLD: 1264 assert( __LINE__, ( not defined $check ) 1265 or ref $check 1266 or $check eq "new" 1267 or $check eq "old", "Error in parameters", 1268 defined $old_new ? ( ref $old_new ? ref $old_new : $old_new ) : "undef", 1269 defined $db_new ? ( ref $db_new ? ref $db_new : $db_new ) : "undef", 1270 defined $old_db ? ( ref $old_db ? ref $old_db : $old_db ) : "undef" ); 1271 1272 NEW: 1273 assert( 1274 __LINE__, 1275 ( not defined $check ) 1276 or ref $check 1277 or $check eq "new" 1278 or $check eq "old", 1279 "Error in parameters", 1280 defined $old_new ? ( ref $old_new ? ref $old_new : $old_new ) : "undef", 1281 defined $db_new ? ( ref $db_new ? ref $db_new : $db_new ) : "undef", 1282 defined $old_db ? ( ref $old_db ? ref $old_db : $old_db ) : "undef" 1283 ); 1284 1285 Another example shows how this helps displaying lists: 1286 1287 OLD: 1288 %{ $self->{COMPONENTS} } = ( 1289 fname => 1290 { type => 'name', adj => 'yes', font => 'Helvetica', 'index' => 0 }, 1291 street => 1292 { type => 'road', adj => 'yes', font => 'Helvetica', 'index' => 2 }, 1293 ); 1294 1295 The structure is clearer with the added indentation: 1296 1297 NEW: 1298 %{ $self->{COMPONENTS} } = ( 1299 fname => 1300 { type => 'name', adj => 'yes', font => 'Helvetica', 'index' => 0 }, 1301 street => 1302 { type => 'road', adj => 'yes', font => 'Helvetica', 'index' => 2 }, 1303 ); 1304 1305 -The structure of nested logical expressions is now displayed better. 1306 Thanks to Wolfgang Weisselberg for helpful discussions. For example, 1307 note how the status of the final 'or' is displayed in the following: 1308 1309 OLD: 1310 return ( !null($op) 1311 and null( $op->sibling ) 1312 and $op->ppaddr eq "pp_null" 1313 and class($op) eq "UNOP" 1314 and ( ( $op->first->ppaddr =~ /^pp_(and|or)$/ 1315 and $op->first->first->sibling->ppaddr eq "pp_lineseq" ) 1316 or ( $op->first->ppaddr eq "pp_lineseq" 1317 and not null $op->first->first->sibling 1318 and $op->first->first->sibling->ppaddr eq "pp_unstack" ) ) ); 1319 1320 NEW: 1321 return ( 1322 !null($op) 1323 and null( $op->sibling ) 1324 and $op->ppaddr eq "pp_null" 1325 and class($op) eq "UNOP" 1326 and ( 1327 ( 1328 $op->first->ppaddr =~ /^pp_(and|or)$/ 1329 and $op->first->first->sibling->ppaddr eq "pp_lineseq" 1330 ) 1331 or ( $op->first->ppaddr eq "pp_lineseq" 1332 and not null $op->first->first->sibling 1333 and $op->first->first->sibling->ppaddr eq "pp_unstack" ) 1334 ) 1335 ); 1336 1337 -A break will always be put before a list item containing a comma-arrow. 1338 This will improve formatting of mixed lists of this form: 1339 1340 OLD: 1341 $c->create( 1342 'text', 225, 20, -text => 'A Simple Plot', 1343 -font => $font, 1344 -fill => 'brown' 1345 ); 1346 1347 NEW: 1348 $c->create( 1349 'text', 225, 20, 1350 -text => 'A Simple Plot', 1351 -font => $font, 1352 -fill => 'brown' 1353 ); 1354 1355 -For convenience, the command -dac (--delete-all-comments) now also 1356 deletes pod. Likewise, -tac (--tee-all-comments) now also sends pod 1357 to a '.TEE' file. Complete control over the treatment of pod and 1358 comments is still possible, as described in the updated help message 1359 and man page. 1360 1361 -The logic which breaks open 'containers' has been rewritten to be completely 1362 symmetric in the following sense: if a line break is placed after an opening 1363 {, [, or (, then a break will be placed before the corresponding closing 1364 token. Thus, a container either remains closed or is completely cracked 1365 open. 1366 1367 -Improved indentation of parenthesized lists. For example, 1368 1369 OLD: 1370 $GPSCompCourse = 1371 int( 1372 atan2( $GPSTempCompLong - $GPSLongitude, 1373 $GPSLatitude - $GPSTempCompLat ) * 180 / 3.14159265 ); 1374 1375 NEW: 1376 $GPSCompCourse = int( 1377 atan2( 1378 $GPSTempCompLong - $GPSLongitude, 1379 $GPSLatitude - $GPSTempCompLat 1380 ) * 180 / 3.14159265 1381 ); 1382 1383 Further improvements will be made in future releases. 1384 1385 -Some improvements were made in formatting small lists. 1386 1387 -Correspondence between Input and Output line numbers reported in a 1388 .LOG file should now be exact. They were sometimes off due to the size 1389 of intermediate buffers. 1390 1391 -Corrected minor tokenization error in which a ';' in a foreach loop 1392 control was tokenized as a statement termination, which forced a 1393 line break: 1394 1395 OLD: 1396 foreach ( $i = 0; 1397 $i <= 10; 1398 $i += 2 1399 ) 1400 { 1401 print "$i "; 1402 } 1403 1404 NEW: 1405 foreach ( $i = 0 ; $i <= 10 ; $i += 2 ) { 1406 print "$i "; 1407 } 1408 1409 -Corrected a problem with reading config files, in which quote marks were not 1410 stripped. As a result, something like -wba="&& . || " would have the leading 1411 quote attached to the && and not work correctly. A workaround for older 1412 versions is to place a space around all tokens within the quotes, like this: 1413 -wba=" && . || " 1414 1415 -Removed any existing space between a label and its ':' 1416 OLD : { } 1417 NEW: { } 1418 This was necessary because the label and its colon are a single token. 1419 1420 -Corrected tokenization error for the following (highly non-recommended) 1421 construct: 1422 $user = @vars[1] / 100; 1423 1424 -Resolved cause of a difference between perltidy under perl v5.6.1 and 1425 5.005_03; the problem was different behavior of \G regex position 1426 marker(!) 1427 1428 2001 10 20 1429 -Corrected a bug in which a break was not being made after a full-line 1430 comment within a short eval/sort/map/grep block. A flag was not being 1431 zeroed. The syntax error check catches this. Here is a snippet which 1432 illustrates the bug: 1433 1434 eval { 1435 #open Socket to Dispatcher 1436 $sock = &OpenSocket; 1437 }; 1438 1439 The formatter mistakenly thought that it had found the following 1440 one-line block: 1441 1442 eval {#open Socket to Dispatcher$sock = &OpenSocket; }; 1443 1444 The patch fixes this. Many thanks to Henry Story for reporting this bug. 1445 1446 -Changes were made to help diagnose and resolve problems in a 1447 .perltidyrc file: 1448 (1) processing of command parameters has been into two separate 1449 batches so that any errors in a .perltidyrc file can be localized. 1450 (2) commands --help, --version, and as many of the --dump-xxx 1451 commands are handled immediately, without any command line processing 1452 at all. 1453 (3) Perltidy will ignore any commands in the .perltidyrc file which 1454 cause immediate exit. These are: -h -v -ddf -dln -dop -dsn -dtt 1455 -dwls -dwrs -ss. Thanks to Wolfgang Weisselberg for helpful 1456 suggestions regarding these updates. 1457 1458 -Syntax check has been reinstated as default for MSWin32 systems. This 1459 way Windows 2000 users will get syntax check by default, which seems 1460 like a better idea, since the number of Win 95/98 systems will be 1461 decreasing over time. Documentation revised to warn Windows 95/98 1462 users about the problem with empty '&1'. Too bad these systems 1463 all report themselves as MSWin32. 1464 1465 2001 10 16 1466 -Fixed tokenization error in which a method call of the form 1467 1468 Module::->new(); 1469 1470 got a space before the '::' like this: 1471 1472 Module ::->new(); 1473 1474 Thanks to David Holden for reporting this. 1475 1476 -Added -html control over pod text, using a new abbreviation 'pd'. See 1477 updated perl2web man page. The default is to use the color of a comment, 1478 but italicized. Old .css style sheets will need a new line for 1479 .pd to use this. The old color was the color of a string, and there 1480 was no control. 1481 1482 -.css lines are now printed in sorted order. 1483 1484 -Fixed interpolation problem where html files had '$input_file' as title 1485 instead of actual input file name. Thanks to Simon Perreault for finding 1486 this and sending a patch, and also to Tobias Weber. 1487 1488 -Breaks will now have the ':' placed at the start of a line, 1489 one per line by default because this shows logical structure 1490 more clearly. This coding has been completely redone. Some 1491 examples of new ?/: formatting: 1492 1493 OLD: 1494 wantarray ? map( $dir::cwd->lookup($_)->path, @_ ) : 1495 $dir::cwd->lookup( $_[0] )->path; 1496 1497 NEW: 1498 wantarray 1499 ? map( $dir::cwd->lookup($_)->path, @_ ) 1500 : $dir::cwd->lookup( $_[0] )->path; 1501 1502 OLD: 1503 $a = ( $b > 0 ) ? { 1504 a => 1, 1505 b => 2 1506 } : { a => 6, b => 8 }; 1507 1508 NEW: 1509 $a = ( $b > 0 ) 1510 ? { 1511 a => 1, 1512 b => 2 1513 } 1514 : { a => 6, b => 8 }; 1515 1516 OLD: (-gnu): 1517 $self->note($self->{skip} ? "Hunk #$self->{hunk} ignored at 1.\n" : 1518 "Hunk #$self->{hunk} failed--$@"); 1519 1520 NEW: (-gnu): 1521 $self->note($self->{skip} 1522 ? "Hunk #$self->{hunk} ignored at 1.\n" 1523 : "Hunk #$self->{hunk} failed--$@"); 1524 1525 OLD: 1526 $which_search = 1527 $opts{"t"} ? 'title' : 1528 $opts{"s"} ? 'subject' : $opts{"a"} ? 'author' : 'title'; 1529 1530 NEW: 1531 $which_search = 1532 $opts{"t"} ? 'title' 1533 : $opts{"s"} ? 'subject' 1534 : $opts{"a"} ? 'author' 1535 : 'title'; 1536 1537 You can use -wba=':' to recover the previous default which placed ':' 1538 at the end of a line. Thanks to Michael Cartmell for helpful 1539 discussions and examples. 1540 1541 -Tokenizer updated to do syntax checking for matched ?/: pairs. Also, 1542 the tokenizer now outputs a unique serial number for every balanced 1543 pair of brace types and ?/: pairs. This greatly simplifies the 1544 formatter. 1545 1546 -Long lines with repeated 'and', 'or', '&&', '||' will now have 1547 one such item per line. For example: 1548 1549 OLD: 1550 if ( $opt_d || $opt_m || $opt_p || $opt_t || $opt_x 1551 || ( -e $archive && $opt_r ) ) 1552 { 1553 ( $pAr, $pNames ) = readAr($archive); 1554 } 1555 1556 NEW: 1557 if ( $opt_d 1558 || $opt_m 1559 || $opt_p 1560 || $opt_t 1561 || $opt_x 1562 || ( -e $archive && $opt_r ) ) 1563 { 1564 ( $pAr, $pNames ) = readAr($archive); 1565 } 1566 1567 OLD: 1568 if ( $vp->{X0} + 4 <= $x && $vp->{X0} + $vp->{W} - 4 >= $x 1569 && $vp->{Y0} + 4 <= $y && $vp->{Y0} + $vp->{H} - 4 >= $y ) 1570 1571 NEW: 1572 if ( $vp->{X0} + 4 <= $x 1573 && $vp->{X0} + $vp->{W} - 4 >= $x 1574 && $vp->{Y0} + 4 <= $y 1575 && $vp->{Y0} + $vp->{H} - 4 >= $y ) 1576 1577 -Long lines with multiple concatenated tokens will have concatenated 1578 terms (see below) placed one per line, except for short items. For 1579 example: 1580 1581 OLD: 1582 $report .= 1583 "Device type:" . $ib->family . " ID:" . $ib->serial . " CRC:" 1584 . $ib->crc . ": " . $ib->model() . "\n"; 1585 1586 NEW: 1587 $report .= "Device type:" 1588 . $ib->family . " ID:" 1589 . $ib->serial . " CRC:" 1590 . $ib->model() 1591 . $ib->crc . ": " . "\n"; 1592 1593 NOTE: at present 'short' means 8 characters or less. There is a 1594 tentative flag to change this (-scl), but it is undocumented and 1595 is likely to be changed or removed later, so only use it for testing. 1596 In the above example, the tokens " ID:", " CRC:", and "\n" are below 1597 this limit. 1598 1599 -If a line which is short enough to fit on a single line was 1600 nevertheless broken in the input file at a 'good' location (see below), 1601 perltidy will try to retain a break. For example, the following line 1602 will be formatted as: 1603 1604 open SUM, "<$file" 1605 or die "Cannot open $file ($!)"; 1606 1607 if it was broken in the input file, and like this if not: 1608 1609 open SUM, "<$file" or die "Cannot open $file ($!)"; 1610 1611 GOOD: 'good' location means before 'and','or','if','unless','&&','||' 1612 1613 The reason perltidy does not just always break at these points is that if 1614 there are multiple, similar statements, this would preclude alignment. So 1615 rather than check for this, perltidy just tries to follow the input style, 1616 in the hopes that the author made a good choice. Here is an example where 1617 we might not want to break before each 'if': 1618 1619 ($Locale, @Locale) = ($English, @English) if (@English > @Locale); 1620 ($Locale, @Locale) = ($German, @German) if (@German > @Locale); 1621 ($Locale, @Locale) = ($French, @French) if (@French > @Locale); 1622 ($Locale, @Locale) = ($Spanish, @Spanish) if (@Spanish > @Locale); 1623 1624 -Added wildcard file expansion for systems with shells which lack this. 1625 Now 'perltidy *.pl' should work under MSDOS/Windows. Thanks to Hugh Myers 1626 for suggesting this. This uses builtin glob() for now; I may change that. 1627 1628 -Added new flag -sbl which, if specified, overrides the value of -bl 1629 for opening sub braces. This allows formatting of this type: 1630 1631 perltidy -sbl 1632 1633 sub foo 1634 { 1635 if (!defined($_[0])) { 1636 print("Hello, World\n"); 1637 } 1638 else { 1639 print($_[0], "\n"); 1640 } 1641 } 1642 Requested by Don Alexander. 1643 1644 -Fixed minor parsing error which prevented a space after a $$ variable 1645 (pid) in some cases. Thanks to Michael Cartmell for noting this. 1646 For example, 1647 old: $$< 700 1648 new: $$ < 700 1649 1650 -Improved line break choices 'and' and 'or' to display logic better. 1651 For example: 1652 1653 OLD: 1654 exists $self->{'build_dir'} and push @e, 1655 "Unwrapped into directory $self->{'build_dir'}"; 1656 1657 NEW: 1658 exists $self->{'build_dir'} 1659 and push @e, "Unwrapped into directory $self->{'build_dir'}"; 1660 1661 -Fixed error of multiple use of abbreviatioin '-dsc'. -dsc remains 1662 abbreviation for delete-side-comments; -dsm is new abbreviation for 1663 delete-semicolons. 1664 1665 -Corrected and updated 'usage' help routine. Thanks to Slaven Rezic for 1666 noting an error. 1667 1668 -The default for Windows is, for now, not to do a 'perl -c' syntax 1669 check (but -syn will activate it). This is because of problems with 1670 command.com. James Freeman sent me a patch which tries to get around 1671 the problems, and it works in many cases, but testing revealed several 1672 issues that still need to be resolved. So for now, the default is no 1673 syntax check for Windows. 1674 1675 -I added a -T flag when doing perl -c syntax check. 1676 This is because I test it on a large number of scripts from sources 1677 unknown, and who knows what might be hidden in initialization blocks? 1678 Also, deactivated the syntax check if perltidy is run as root. As a 1679 benign example, running the previous version of perltidy on the 1680 following file would cause it to disappear: 1681 1682 BEGIN{ 1683 print "Bye, bye baby!\n"; 1684 unlink $0; 1685 } 1686 1687 The new version will not let that happen. 1688 1689 -I am contemplating (but have not yet implemented) making '-lp' the 1690 default indentation, because it is stable now and may be closer to how 1691 perl is commonly formatted. This could be in the next release. The 1692 reason that '-lp' was not the original default is that the coding for 1693 it was complex and not ready for the initial release of perltidy. If 1694 anyone has any strong feelings about this, I'd like to hear. The 1695 current default could always be recovered with the '-nlp' flag. 1696 1697 2001 09 03 1698 -html updates: 1699 - sub definition names are now specially colored, red by default. 1700 The letter 'm' is used to identify them. 1701 - keyword 'sub' now has color of other keywords. 1702 - restored html keyword color to __END__ and __DATA__, which was 1703 accidentally removed in the previous version. 1704 1705 -A new -se (--standard-error-output) flag has been implemented and 1706 documented which causes all errors to be written to standard output 1707 instead of a .ERR file. 1708 1709 -A new -w (--warning-output) flag has been implemented and documented 1710 which causes perltidy to output certain non-critical messages to the 1711 error output file, .ERR. These include complaints about pod usage, 1712 for example. The default is to not include these. 1713 1714 NOTE: This replaces an undocumented -w=0 or --warning-level flag 1715 which was tentatively introduced in the previous version to avoid some 1716 unwanted messages. The new default is the same as the old -w=0, so 1717 that is no longer needed. 1718 1719 -Improved syntax checking and corrected tokenization of functions such 1720 as rand, srand, sqrt, ... These can accept either an operator or a term 1721 to their right. This has been corrected. 1722 1723 -Corrected tokenization of semicolon: testing of the previous update showed 1724 that the semicolon in the following statement was being mis-tokenized. That 1725 did no harm, other than adding an extra blank space, but has been corrected. 1726 1727 for (sort {strcoll($a,$b);} keys %investments) { 1728 ... 1729 } 1730 1731 -New syntax check: after wasting 5 minutes trying to resolve a syntax 1732 error in which I had an extra terminal ';' in a complex for (;;) statement, 1733 I spent a few more minutes adding a check for this in perltidy so it won't 1734 happen again. 1735 1736 -The behavior of --break-before-subs (-bbs) and --break-before-blocks 1737 (-bbb) has been modified. Also, a new control parameter, 1738 --long-block-line-count=n (-lbl=n) has been introduced to give more 1739 control on -bbb. This was previously a hardwired value. The reason 1740 for the change is to reduce the number of unwanted blank lines that 1741 perltidy introduces, and make it less erratic. It's annoying to remove 1742 an unwanted blank line and have perltidy put it back. The goal is to 1743 be able to sprinkle a few blank lines in that dense script you 1744 inherited from Bubba. I did a lot of experimenting with different 1745 schemes for introducing blank lines before and after code blocks, and 1746 decided that there is no really good way to do it. But I think the new 1747 scheme is an improvement. You can always deactivate this with -nbbb. 1748 I've been meaning to work on this; thanks to Erik Thaysen for bringing 1749 it to my attention. 1750 1751 -The .LOG file is seldom needed, and I get tired of deleting them, so 1752 they will now only be automatically saved if perltidy thinks that it 1753 made an error, which is almost never. You can still force the logfile 1754 to be saved with -log or -g. 1755 1756 -Improved method for computing number of columns in a table. The old 1757 method always tried for an even number. The new method allows odd 1758 numbers when it is obvious that a list is not a hash initialization 1759 list. 1760 1761 old: my ( 1762 $name, $xsargs, $parobjs, $optypes, 1763 $hasp2child, $pmcode, $hdrcode, $inplacecode, 1764 $globalnew, $callcopy 1765 ) 1766 = @_; 1767 1768 new: my ( 1769 $name, $xsargs, $parobjs, $optypes, $hasp2child, 1770 $pmcode, $hdrcode, $inplacecode, $globalnew, $callcopy 1771 ) 1772 = @_; 1773 1774 -I fiddled with the list threshold adjustment, and some small lists 1775 look better now. Here is the change for one of the lists in test file 1776 'sparse.t': 1777 old: 1778 %units = 1779 ("in", "in", "pt", "pt", "pc", "pi", "mm", "mm", "cm", "cm", "\\hsize", "%", 1780 "\\vsize", "%", "\\textwidth", "%", "\\textheight", "%"); 1781 1782 new: 1783 %units = ( 1784 "in", "in", "pt", "pt", "pc", "pi", 1785 "mm", "mm", "cm", "cm", "\\hsize", "%", 1786 "\\vsize", "%", "\\textwidth", "%", "\\textheight", "%" 1787 ); 1788 1789 -Improved -lp formatting at '=' sign. A break was always being added after 1790 the '=' sign in a statement such as this, (to be sure there was enough room 1791 for the parameters): 1792 1793 old: my $fee = 1794 CalcReserveFee( 1795 $env, $borrnum, 1796 $biblionumber, $constraint, 1797 $bibitems 1798 ); 1799 1800 The updated version doesn't do this unless the space is really needed: 1801 1802 new: my $fee = CalcReserveFee( 1803 $env, $borrnum, 1804 $biblionumber, $constraint, 1805 $bibitems 1806 ); 1807 1808 -I updated the tokenizer to allow $#+ and $#-, which seem to be new to 1809 Perl 5.6. Some experimenting with a recent version of Perl indicated 1810 that it allows these non-alphanumeric '$#' array maximum index 1811 varaibles: $#: $#- $#+ so I updated the parser accordingly. Only $#: 1812 seems to be valid in older versions of Perl. 1813 1814 -Fixed a rare formatting problem with -lp (and -gnu) which caused 1815 excessive indentation. 1816 1817 -Many additional syntax checks have been added. 1818 1819 -Revised method for testing here-doc target strings; the following 1820 was causing trouble with a regex test because of the '*' characters: 1821 print <<"*EOF*"; 1822 bla bla 1823 *EOF* 1824 Perl seems to allow almost anything to be a here doc target, so an 1825 exact string comparison is now used. 1826 1827 -Made update to allow underscores in binary numbers, like '0b1100_0000'. 1828 1829 -Corrected problem with scanning certain module names; a blank space was 1830 being inserted after 'warnings' in the following: 1831 use warnings::register; 1832 The problem was that warnings (and a couple of other key modules) were 1833 being tokenized as keywords. They should have just been identifiers. 1834 1835 -Corrected tokenization of indirect objects after sort, system, and exec, 1836 after testing produced an incorrect error message for the following 1837 line of code: 1838 print sort $sortsubref @list; 1839 1840 -Corrected minor problem where a line after a format had unwanted 1841 extra continuation indentation. 1842 1843 -Delete-block-comments (and -dac) now retain any leading hash-bang line 1844 1845 -Update for -lp (and -gnu) to not align the leading '=' of a list 1846 with a previous '=', since this interferes with alignment of parameters. 1847 1848 old: my $hireDay = new Date; 1849 my $self = { 1850 firstName => undef, 1851 lastName => undef, 1852 hireDay => $hireDay 1853 }; 1854 1855 new: my $hireDay = new Date; 1856 my $self = { 1857 firstName => undef, 1858 lastName => undef, 1859 hireDay => $hireDay 1860 }; 1861 1862 -Modifications made to display tables more compactly when possible, 1863 without adding lines. For example, 1864 old: 1865 '1', "I", '2', "II", '3', "III", '4', "IV", 1866 '5', "V", '6', "VI", '7', "VII", '8', "VIII", 1867 '9', "IX" 1868 new: 1869 '1', "I", '2', "II", '3', "III", 1870 '4', "IV", '5', "V", '6', "VI", 1871 '7', "VII", '8', "VIII", '9', "IX" 1872 1873 -Corrected minor bug in which -pt=2 did not keep the right paren tight 1874 around a '++' or '--' token, like this: 1875 1876 for ($i = 0 ; $i < length $key ; $i++ ) 1877 1878 The formatting for this should be, and now is: 1879 1880 for ($i = 0 ; $i < length $key ; $i++) 1881 1882 Thanks to Erik Thaysen for noting this. 1883 1884 -Discovered a new bug involving here-docs during testing! See BUGS.html. 1885 1886 -Finally fixed parsing of subroutine attributes (A Perl 5.6 feature). 1887 However, the attributes and prototypes must still be on the same line 1888 as the sub name. 1889 1890 2001 07 31 1891 -Corrected minor, uncommon bug found during routine testing, in which a 1892 blank got inserted between a function name and its opening paren after 1893 a file test operator, but only in the case that the function had not 1894 been previously seen. Perl uses the existance (or lack thereof) of 1895 the blank to guess if it is a function call. That is, 1896 if (-l pid_filename()) { 1897 became 1898 if (-l pid_filename ()) { 1899 which is a syntax error if pid_filename has not been seen by perl. 1900 1901 -If the AutoLoader module is used, perltidy will continue formatting 1902 code after seeing an __END__ line. Use -nlal to deactivate this feature. 1903 Likewise, if the SelfLoader module is used, perltidy will continue 1904 formatting code after seeing a __DATA__ line. Use -nlsl to 1905 deactivate this feature. Thanks to Slaven Rezic for this suggestion. 1906 1907 -pod text after __END__ and __DATA__ is now identified by perltidy 1908 so that -dp works correctly. Thanks to Slaven Rezic for this suggestion. 1909 1910 -The first $VERSION line which might be eval'd by MakeMaker 1911 is now passed through unchanged. Use -npvl to deactivate this feature. 1912 Thanks to Manfred Winter for this suggestion. 1913 1914 -Improved indentation of nested parenthesized expressions. Tests have 1915 given favorable results. Thanks to Wolfgang Weisselberg for helpful 1916 examples. 1917 1918 2001 07 23 1919 -Fixed a very rare problem in which an unwanted semicolon was inserted 1920 due to misidentification of anonymous hash reference curly as a code 1921 block curly. (No instances of this have been reported; I discovered it 1922 during testing). A workaround for older versions of perltidy is to use 1923 -nasc. 1924 1925 -Added -icb (-indent-closing-brace) parameter to indent a brace which 1926 terminates a code block to the same level as the previous line. 1927 Suggested by Andrew Cutler. For example, 1928 1929 if ($task) { 1930 yyy(); 1931 } # -icb 1932 else { 1933 zzz(); 1934 } 1935 1936 -Rewrote error message triggered by an unknown bareword in a print or 1937 printf filehandle position, and added flag -w=0 to prevent issuing this 1938 error message. Suggested by Byron Jones. 1939 1940 -Added modification to align a one-line 'if' block with similar 1941 following 'elsif' one-line blocks, like this: 1942 if ( $something eq "simple" ) { &handle_simple } 1943 elsif ( $something eq "hard" ) { &handle_hard } 1944 (Suggested by Wolfgang Weisselberg). 1945 1946 2001 07 02 1947 -Eliminated all constants with leading underscores because perl 5.005_03 1948 does not support that. For example, _SPACES changed to XX_SPACES. 1949 Thanks to kromJx for this update. 1950 1951 2001 07 01 1952 -the directory of test files has been moved to a separate distribution 1953 file because it is getting large but is of little interest to most users. 1954 For the current distribution: 1955 perltidy-20010701.tgz contains the source and docs for perltidy 1956 perltidy-20010701-test.tgz contains the test files 1957 1958 -fixed bug where temporary file perltidy.TMPI was not being deleted 1959 when input was from stdin. 1960 1961 -adjusted line break logic to not break after closing brace of an 1962 eval block (suggested by Boris Zentner). 1963 1964 -added flag -gnu (--gnu-style) to give an approximation to the GNU 1965 style as sometimes applied to perl. The programming style in GNU 1966 'automake' was used as a guide in setting the parameters; these 1967 parameters will probably be adjusted over time. 1968 1969 -an empty code block now has one space for emphasis: 1970 if ( $cmd eq "bg_untested" ) {} # old 1971 if ( $cmd eq "bg_untested" ) { } # new 1972 If this bothers anyone, we could create a parameter. 1973 1974 -the -bt (--brace-tightness) parameter has been split into two 1975 parameters to give more control. -bt now applies only to non-BLOCK 1976 braces, while a new parameter -bbt (block-brace-tightness) applies to 1977 curly braces which contain code BLOCKS. The default value is -bbt=0. 1978 1979 -added flag -icp (--indent-closing-paren) which leaves a statment 1980 termination of the form );, };, or ]; indented with the same 1981 indentation as the previous line. For example, 1982 1983 @month_of_year = ( # default, or -nicp 1984 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 1985 'Nov', 'Dec' 1986 ); 1987 1988 @month_of_year = ( # -icp 1989 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 1990 'Nov', 'Dec' 1991 ); 1992 1993 -Vertical alignment updated to synchronize with tokens &&, ||, 1994 and, or, if, unless. Allowable space before forcing 1995 resynchronization has been increased. (Suggested by Wolfgang 1996 Weisselberg). 1997 1998 -html corrected to use -nohtml-bold-xxxxxxx or -nhbx to negate bold, 1999 and likewise -nohtml-italic-xxxxxxx or -nhbi to negate italic. There 2000 was no way to negate these previously. html documentation updated and 2001 corrected. (Suggested by Wolfgang Weisselberg). 2002 2003 -Some modifications have been made which improve the -lp formatting in 2004 a few cases. 2005 2006 -Perltidy now retains or creates a blank line after an =cut to keep 2007 podchecker happy (Suggested by Manfred H. Winter). This appears to be 2008 a glitch in podchecker, but it was annoying. 2009 2010 2001 06 17 2011 -Added -bli flag to give continuation indentation to braces, like this 2012 2013 if ($bli_flag) 2014 { 2015 extra_indentation(); 2016 } 2017 2018 -Corrected an error with the tab (-t) option which caused the last line 2019 of a multi-line quote to receive a leading tab. This error was in 2020 version 2001 06 08 but not 2001 04 06. If you formatted a script 2021 with -t with this version, please check it by running once with the 2022 -chk flag and perltidy will scan for this possible error. 2023 2024 -Corrected an invalid pattern (\R should have been just R), changed 2025 $^W =1 to BEGIN {$^W=1} to use warnings in compile phase, and corrected 2026 several unnecessary 'my' declarations. Many thanks to Wolfgang Weisselberg, 2027 2001-06-12, for catching these errors. 2028 2029 -A '-bar' flag has been added to require braces to always be on the 2030 right, even for multi-line if and foreach statements. For example, 2031 the default formatting of a long if statement would be: 2032 2033 if ($bigwasteofspace1 && $bigwasteofspace2 2034 || $bigwasteofspace3 && $bigwasteofspace4) 2035 { 2036 bigwastoftime(); 2037 } 2038 2039 With -bar, the formatting is: 2040 2041 if ($bigwasteofspace1 && $bigwasteofspace2 2042 || $bigwasteofspace3 && $bigwasteofspace4) { 2043 bigwastoftime(); 2044 } 2045 Suggested by Eli Fidler 2001-06-11. 2046 2047 -Uploaded perltidy to sourceforge cvs 2001-06-10. 2048 2049 -An '-lp' flag (--line-up-parentheses) has been added which causes lists 2050 to be indented with extra indentation in the manner sometimes 2051 associated with emacs or the GNU suggestions. Thanks to Ian Stuart for 2052 this suggestion and for extensive help in testing it. 2053 2054 -Subroutine call parameter lists are now formatted as other lists. 2055 This should improve formatting of tables being passed via subroutine 2056 calls. This will also cause full indentation ('-i=n, default n= 4) of 2057 continued parameter list lines rather than just the number of spaces 2058 given with -ci=n, default n=2. 2059 2060 -Added support for hanging side comments. Perltidy identifies a hanging 2061 side comment as a comment immediately following a line with a side 2062 comment or another hanging side comment. This should work in most 2063 cases. It can be deactivated with --no-hanging-side-comments (-nhsc). 2064 The manual has been updated to discuss this. Suggested by Brad 2065 Eisenberg some time ago, and finally implemented. 2066 2067 2001 06 08 2068 -fixed problem with parsing command parameters containing quoted 2069 strings in .perltidyrc files. (Reported by Roger Espel Llima 2001-06-07). 2070 2071 -added two command line flags, --want-break-after and 2072 --want-break-before, which allow changing whether perltidy 2073 breaks lines before or after any operators. Please see the revised 2074 man pages for details. 2075 2076 -added system-wide configuration file capability. 2077 If perltidy does not find a .perltidyrc command line file in 2078 the current directory, nor in the home directory, it now looks 2079 for '/usr/local/etc/perltidyrc' and then for '/etc/perltidyrc'. 2080 (Suggested by Roger Espel Llima 2001-05-31). 2081 2082 -fixed problem in which spaces were trimmed from lines of a multi-line 2083 quote. (Reported by Roger Espel Llima 2001-05-30). This is an 2084 uncommon situation, but serious, because it could conceivably change 2085 the proper function of a script. 2086 2087 -fixed problem in which a semicolon was incorrectly added within 2088 an anonymous hash. (Reported by A.C. Yardley, 2001-5-23). 2089 (You would know if this happened, because perl would give a syntax 2090 error for the resulting script). 2091 2092 -fixed problem in which an incorrect error message was produced 2093 after a version number on a 'use' line, like this ( Reported 2094 by Andres Kroonmaa, 2001-5-14): 2095 2096 use CGI 2.42 qw(fatalsToBrowser); 2097 2098 Other than the extraneous error message, this bug was harmless. 2099 2100 2001 04 06 2101 -fixed serious bug in which the last line of some multi-line quotes or 2102 patterns was given continuation indentation spaces. This may make 2103 a pattern incorrect unless it uses the /x modifier. To find 2104 instances of this error in scripts which have been formatted with 2105 earlier versions of perltidy, run with the -chk flag, which has 2106 been added for this purpose (SLH, 2001-04-05). 2107 2108 ** So, please check previously formatted scripts by running with -chk 2109 at least once ** 2110 2111 -continuation indentation has been reprogrammed to be hierarchical, 2112 which improves deeply nested structures. 2113 2114 -fixed problem with undefined value in list formatting (reported by Michael 2115 Langner 2001-04-05) 2116 2117 -Switched to graphical display of nesting in .LOG files. If an 2118 old format string was "(1 [0 {2", the new string is "{{(". This 2119 is easier to read and also shows the order of nesting. 2120 2121 -added outdenting of cuddled paren structures, like ")->pack(". 2122 2123 -added line break and outdenting of ')->' so that instead of 2124 2125 $mw->Label( 2126 -text => "perltidy", 2127 -relief => 'ridge')->pack; 2128 2129 the current default is: 2130 2131 $mw->Label( 2132 -text => "perltidy", 2133 -relief => 'ridge' 2134 )->pack; 2135 2136 (requested by Michael Langner 2001-03-31; in the future this could 2137 be controlled by a command-line parameter). 2138 2139 -revised list indentation logic, so that lists following an assignment 2140 operator get one full indentation level, rather than just continuation 2141 indentation. Also corrected some minor glitches in the continuation 2142 indentation logic. 2143 2144 -Fixed problem with unwanted continuation indentation after a blank line 2145 (reported by Erik Thaysen 2001-03-28): 2146 2147 -minor update to avoid stranding a single '(' on one line 2148 2149 2001 03 28: 2150 -corrected serious error tokenizing filehandles, in which a sub call 2151 after a print or printf, like this: 2152 print usage() and exit; 2153 became this: 2154 print usage () and exit; 2155 Unfortunately, this converts 'usage' to a filehandle. To fix this, rerun 2156 perltidy; it will look for this situation and issue a warning. 2157 2158 -fixed another cuddled-else formatting bug (Reported by Craig Bourne) 2159 2160 -added several diagnostic --dump routines 2161 2162 -added token-level whitespace controls (suggested by Hans Ecke) 2163 2164 2001 03 23: 2165 -added support for special variables of the form ${^WANT_BITS} 2166 2167 -space added between scalar and left paren in 'for' and 'foreach' loops, 2168 (suggestion by Michael Cartmell): 2169 2170 for $i( 1 .. 20 ) # old 2171 for $i ( 1 .. 20 ) # new 2172 2173 -html now outputs cascading style sheets (thanks to suggestion from 2174 Hans Ecke) 2175 2176 -flags -o and -st now work with -html 2177 2178 -added missing -html documentation for comments (noted by Alex Izvorski) 2179 2180 -support for VMS added (thanks to Michael Cartmell for code patches and 2181 testing) 2182 2183 -v-strings implemented (noted by Hans Ecke and Michael Cartmell; extensive 2184 testing by Michael Cartmell) 2185 2186 -fixed problem where operand may be empty at line 3970 2187 (\b should be just b in lines 3970, 3973) (Thanks to Erik Thaysen, 2188 Keith Marshall for bug reports) 2189 2190 -fixed -ce bug (cuddled else), where lines like '} else {' were indented 2191 (Thanks to Shawn Stepper and Rick Measham for reporting this) 2192 2193 2001 03 04: 2194 -fixed undefined value in line 153 (only worked with -I set) 2195 (Thanks to Mike Stok, Phantom of the Opcodes, Ian Ehrenwald, and others) 2196 2197 -fixed undefined value in line 1069 (filehandle problem with perl versions < 2198 5.6) (Thanks to Yuri Leikind, Mike Stok, Michael Holve, Jeff Kolber) 2199 2200 2001 03 03: 2201 -Initial announcement at freshmeat.net; started Change Log 2202 (Unfortunately this version was DOA, but it was fixed the next day) 2203