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