Hello community, here is the log from the commit of package perl-Perl-Tidy for openSUSE:Factory checked in at 2014-09-17 17:25:51 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-Perl-Tidy (Old) and /work/SRC/openSUSE:Factory/.perl-Perl-Tidy.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "perl-Perl-Tidy" Changes: -------- --- /work/SRC/openSUSE:Factory/perl-Perl-Tidy/perl-Perl-Tidy.changes 2013-10-06 14:55:30.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.perl-Perl-Tidy.new/perl-Perl-Tidy.changes 2014-09-17 17:26:09.000000000 +0200 @@ -1,0 +2,39 @@ +Mon Sep 15 15:44:35 UTC 2014 - coolo@suse.com + +- updated to 20140711 + - Fixed RT #94902: abbreviation parsing in .perltidyrc files was not + working for multi-line abbreviations. Thanks to Eric Fung for + supplying a patch. + + - Fixed RT #95708, misparsing of a hash when the first key was a perl + keyword, causing a semicolon to be incorrectly added. + + - Fixed RT #94338 for-loop in a parenthesized block-map. A code block within + parentheses of a map, sort, or grep function was being mistokenized. In + rare cases this could produce in an incorrect error message. The fix will + produce some minor formatting changes. Thanks to Daniel Trizen + discovering and documenting this. + + - Fixed RT #94354, excess indentation for stacked tokens. Thanks to + Colin Williams for supplying a patch. + + - Added support for experimental postfix dereferencing notation introduced in + perl 5.20. RT #96021. + + - Updated documentation to clarify the behavior of the -io flag + in response to RT #95709. You can add -noll or -l=0 to prevent + long comments from being outdented when -io is used. + + - Added a check to prevent a problem reported in RT #81866, where large + scripts which had been compressed to a single line could not be formatted + because of a check for VERSION for MakeMaker. The workaround was to + use -nvpl, but this shouldn't be necessary now. + + - Fixed RT #96101; Closing brace of anonymous sub in a list was being + indented. For example, the closing brace of the anonymous sub below + will now be lined up with the word 'callback'. This problem + occured if there was no comma after the closing brace of the anonymous sub. + This update may cause minor changes to formatting of code with lists + of anonymous subs, especially TK code. + +------------------------------------------------------------------- Old: ---- Perl-Tidy-20130922.tar.gz New: ---- Perl-Tidy-20140711.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-Perl-Tidy.spec ++++++ --- /var/tmp/diff_new_pack.UYH3wu/_old 2014-09-17 17:26:11.000000000 +0200 +++ /var/tmp/diff_new_pack.UYH3wu/_new 2014-09-17 17:26:11.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package perl-Perl-Tidy # -# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: perl-Perl-Tidy -Version: 20130922 +Version: 20140711 Release: 0 %define cpan_name Perl-Tidy Summary: Parses and beautifies perl source @@ -29,8 +29,6 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: perl BuildRequires: perl-macros -#BuildRequires: perl(Perl::Tidy) -#BuildRequires: perl(Text::Autoformat) %{perl_requires} %description @@ -51,7 +49,6 @@ %prep %setup -q -n %{cpan_name}-%{version} -find . -type f -print0 | xargs -0 chmod 644 %build %{__perl} Makefile.PL INSTALLDIRS=vendor ++++++ Perl-Tidy-20130922.tar.gz -> Perl-Tidy-20140711.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Perl-Tidy-20130922/BUGS new/Perl-Tidy-20140711/BUGS --- old/Perl-Tidy-20130922/BUGS 2012-07-01 17:58:18.000000000 +0200 +++ new/Perl-Tidy-20140711/BUGS 2014-03-28 02:03:28.000000000 +0100 @@ -30,6 +30,9 @@ correctly. Perltidy does not handle UTF-8 encoded files + This has long been requested but unfortunately I don't have time, so + it won't happen unless someone wants to work on it. + Two iterations are sometimes needed Usually the code produced by perltidy on the first pass does not change if it is run again, but sometimes a second pass will produce some small diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Perl-Tidy-20130922/CHANGES new/Perl-Tidy-20140711/CHANGES --- old/Perl-Tidy-20130922/CHANGES 2013-09-22 16:40:31.000000000 +0200 +++ new/Perl-Tidy-20140711/CHANGES 2014-07-11 13:16:51.000000000 +0200 @@ -1,4 +1,86 @@ Perltidy Change Log + 2014 07 11 + - Fixed RT #94902: abbreviation parsing in .perltidyrc files was not + working for multi-line abbreviations. Thanks to Eric Fung for + supplying a patch. + + - Fixed RT #95708, misparsing of a hash when the first key was a perl + keyword, causing a semicolon to be incorrectly added. + + - Fixed RT #94338 for-loop in a parenthesized block-map. A code block within + parentheses of a map, sort, or grep function was being mistokenized. In + rare cases this could produce in an incorrect error message. The fix will + produce some minor formatting changes. Thanks to Daniel Trizen + discovering and documenting this. + + - Fixed RT #94354, excess indentation for stacked tokens. Thanks to + Colin Williams for supplying a patch. + + - Added support for experimental postfix dereferencing notation introduced in + perl 5.20. RT #96021. + + - Updated documentation to clarify the behavior of the -io flag + in response to RT #95709. You can add -noll or -l=0 to prevent + long comments from being outdented when -io is used. + + - Added a check to prevent a problem reported in RT #81866, where large + scripts which had been compressed to a single line could not be formatted + because of a check for VERSION for MakeMaker. The workaround was to + use -nvpl, but this shouldn't be necessary now. + + - Fixed RT #96101; Closing brace of anonymous sub in a list was being + indented. For example, the closing brace of the anonymous sub below + will now be lined up with the word 'callback'. This problem + occured if there was no comma after the closing brace of the anonymous sub. + This update may cause minor changes to formatting of code with lists + of anonymous subs, especially TK code. + + # OLD + my @menu_items = ( + + #... + { + path => '/_Operate/Transcode and split', + callback => sub { + return 1 if not $self->project_opened; + $self->comp('project')->transcode( split => 1 ); + } + } + ); + + # NEW + my @menu_items = ( + + #... + { + path => '/_Operate/Transcode and split', + callback => sub { + return 1 if not $self->project_opened; + $self->comp('project')->transcode( split => 1 ); + } + } + ); + + 2014 03 28 + - Fixed RT #94190 and debian Bug #742004: perltidy.LOG file left behind. + Thanks to George Hartzell for debugging this. The problem was + caused by the memoization speedup patch in version 20121207. An + unwanted flag was being set which caused a LOG to be written if + perltidy was called multiple times. + + - New default behavior for LOG files: If the source is from an array or + string (through a call to the perltidy module) then a LOG output is only + possible if a logfile stream is specified. This is to prevent + unexpected perltidy.LOG files. + + - Fixed debian Bug #740670, insecure temporary file usage. File::Temp is now + used to get a temporary file. Thanks to Don Anderson for a patch. + + - Any -b (--backup-and-modify-in-place) flag is silently ignored when a + source stream, destination stream, or standard output is used. + This is because the -b flag may have been in a .perltidyrc file and + warnings break Test::NoWarnings. Thanks to Marijn Brand. + 2013 09 22 - Fixed RT #88020. --converge was not working with wide characters. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Perl-Tidy-20130922/MANIFEST new/Perl-Tidy-20140711/MANIFEST --- old/Perl-Tidy-20130922/MANIFEST 2013-07-17 00:34:49.000000000 +0200 +++ new/Perl-Tidy-20140711/MANIFEST 2014-03-28 01:54:27.000000000 +0100 @@ -8,10 +8,6 @@ README TODO bin/perltidy -debian/changelog -debian/control -debian/copyright -debian/rules docs/README docs/perltidy.1 docs/stylekey.pod diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Perl-Tidy-20130922/META.yml new/Perl-Tidy-20140711/META.yml --- old/Perl-Tidy-20130922/META.yml 2013-09-22 16:43:36.000000000 +0200 +++ new/Perl-Tidy-20140711/META.yml 2014-07-11 13:21:00.000000000 +0200 @@ -1,10 +1,10 @@ --- #YAML:1.0 name: Perl-Tidy -version: 20130922 +version: 20140711 abstract: indent and reformat perl scripts author: - Steve Hancock <perltidy@perltidy.sourceforge.net> -license: unknown +license: GPL-2.0+ distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Perl-Tidy-20130922/Makefile.PL new/Perl-Tidy-20140711/Makefile.PL --- old/Perl-Tidy-20130922/Makefile.PL 2002-04-08 21:51:52.000000000 +0200 +++ new/Perl-Tidy-20140711/Makefile.PL 2014-03-27 22:31:00.000000000 +0100 @@ -14,6 +14,7 @@ $] >= 5.005 ? ( ABSTRACT => 'indent and reformat perl scripts', + LICENSE => 'GPL-2.0+', AUTHOR => 'Steve Hancock <perltidy@perltidy.sourceforge.net>' ) : () diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Perl-Tidy-20130922/TODO new/Perl-Tidy-20140711/TODO --- old/Perl-Tidy-20130922/TODO 2012-07-01 18:10:14.000000000 +0200 +++ new/Perl-Tidy-20140711/TODO 2014-03-28 01:59:50.000000000 +0100 @@ -1,17 +1,9 @@ Perltidy TODO List This is a partial "wish-list" of features to add and things to do. - Provide an option to ignore side comments when checking line length. - That is, side comments would be allowed to be arbitrarily long without - influencing line breaks. - Improved Vertical Alignment There are still many opportunities for improving vertical alignment. - Minimize the instances in which formatting changes on a second iteration. - - Add a convergence test when -it=n is used - Documentation A FAQ is needed to explain some of the more subtle formatting issues, and to give examples of different styles. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Perl-Tidy-20130922/bin/perltidy new/Perl-Tidy-20140711/bin/perltidy --- old/Perl-Tidy-20130922/bin/perltidy 2013-09-22 16:43:35.000000000 +0200 +++ new/Perl-Tidy-20140711/bin/perltidy 2014-07-11 13:20:58.000000000 +0200 @@ -503,10 +503,10 @@ =item B<-io>, B<--indent-only> -This flag is used to deactivate all formatting and line break changes +This flag is used to deactivate all whitespace and line break changes within non-blank lines of code. When it is in effect, the only change to the script will be -to the indentation and blank lines. +to the indentation and to the number of blank lines. And any flags controlling whitespace and newlines will be ignored. You might want to use this if you are perfectly happy with your whitespace and line breaks, and merely want perltidy to handle the indentation. @@ -520,6 +520,11 @@ If you also want to keep your existing blank lines exactly as they are, you can add B<--freeze-blank-lines>. +With this option perltidy is still free to modify the indenting (and +outdenting) of code and comments as it normally would. If you also want to +prevent long comment lines from being outdented, you can add either B<-noll> or +B<-l=0>. + =item B<-ole=s>, B<--output-line-ending=s> where s=C<win>, C<dos>, C<unix>, or C<mac>. This flag tells perltidy @@ -2577,8 +2582,8 @@ } where B<newword> is the abbreviation, and B<opt1>, etc, are existing parameters -I<or other abbreviations>. The main syntax requirement is that -the new abbreviation must begin on a new line. +I<or other abbreviations>. The main syntax requirement is that the new +abbreviation along with its opening curly brace must begin on a new line. Space before and after the curly braces is optional. For a specific example, the following line @@ -3093,7 +3098,7 @@ =head1 VERSION -This man page documents perltidy version 20130922. +This man page documents perltidy version 20140711. =head1 CREDITS diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Perl-Tidy-20130922/debian/changelog new/Perl-Tidy-20140711/debian/changelog --- old/Perl-Tidy-20130922/debian/changelog 2013-08-06 01:33:28.000000000 +0200 +++ new/Perl-Tidy-20140711/debian/changelog 1970-01-01 01:00:00.000000000 +0100 @@ -1,151 +0,0 @@ -perltidy (20130805-1) unstable; urgency=low - - * New upstream release - - -- Steve Hancock <perltidy@users.sourceforge.net> Mon, 05 Aug 2013 06:59:59 -0700 - -perltidy (20121207-1) unstable; urgency=low - - * New upstream release - - -- Steve Hancock <perltidy@users.sourceforge.net> Wed, 17 Jul 2013 06:59:59 -0700 - -perltidy (20121207-1) unstable; urgency=low - - * new upstream release - - -- steve hancock <perltidy@users.sourceforge.net> fri, 07 dec 2012 06:59:59 -0700 - -perltidy (20120717-1) unstable; urgency=low - - * New upstream release - - -- Steve Hancock <perltidy@users.sourceforge.net> Tue, 17 Jul 2012 06:59:59 -0700 - -perltidy (20120714-1) unstable; urgency=low - - * New upstream release - - -- Steve Hancock <perltidy@users.sourceforge.net> Sat, 14 Jul 2012 06:59:59 -0700 - -perltidy (20120701-1) unstable; urgency=low - - * New upstream release - - -- Steve Hancock <perltidy@users.sourceforge.net> Sun, 01 Jul 2012 06:59:59 -0700 - -perltidy (20120619-1) unstable; urgency=low - - * New upstream release - - -- Steve Hancock <perltidy@users.sourceforge.net> Tue, 19 Jun 2012 06:59:59 -0700 - -perltidy (20101217-1) unstable; urgency=low - - * New upstream release - - -- Steve Hancock <perltidy@users.sourceforge.net> Fri, 17 Dec 2010 06:59:59 -0700 - -perltidy (20090616-1) unstable; urgency=low - - * New upstream release - - -- Steve Hancock <perltidy@users.sourceforge.net> Tue, 16 Jun 2009 06:59:59 -0700 - -perltidy (20071205-1) unstable; urgency=low - - * New upstream release - - -- Steve Hancock <perltidy@users.sourceforge.net> Wed, 05 Dec 2007 09:54:33 -0800 - -perltidy (20070801-1) unstable; urgency=low - - * New upstream release - - -- Steve Hancock <perltidy@users.sourceforge.net> Tue, 31 Jul 2007 19:12:50 -0700 - -perltidy (20070508-1) unstable; urgency=low - - * New upstream release - - -- Steve Hancock <perltidy@users.sourceforge.net> Tue, 08 May 2007 13:04:28 -0700 - -perltidy (20070504-1) unstable; urgency=low - - * New upstream release - - -- Steve Hancock <perltidy@users.sourceforge.net> Fri, 04 May 2007 07:03:29 -0700 - -perltidy (20070424-1) unstable; urgency=low - - * New upstream release - - -- Steve Hancock <perltidy@users.sourceforge.net> Tue, 24 Apr 2007 16:40:09 -0700 - -perltidy (20060719-1) unstable; urgency=low - - * New upstream release - - - -- Steve Hancock <perltidy@users.sourceforge.net> Wed, 19 Jul 2006 16:16:15 -0700 - -perltidy (20060614-1) unstable; urgency=low - - * New upstream release - - -- Steve Hancock <perltidy@users.sourceforge.net> Tue, 13 Jun 2006 18:59:02 -0700 - - -perltidy (20031021-1) unstable; urgency=low - - * New upstream release - - -- Steve Hancock <perltidy@users.sourceforge.net> Tue, 21 Oct 2003 20:50:49 -0700 - -perltidy (20030726-1) unstable; urgency=low - - * New upstream - * Changed Build-Depends perl (>= 5.8.0-7) to perl (>=5.6.1-7) - - -- Steve Hancock <perltidy@users.sourceforge.net> Sat, 26 Jul 2003 07:18:13 -0700 - -perltidy (20021130-1) unstable; urgency=low - - * New upstream - * Redid all debian packaging from scratch - - -- Aubin Paul <aubin@punknews.org> Sat, 30 Nov 2002 23:34:34 -0500 - -perltidy (20011020-1) unstable; urgency=low - - * New upstream release. - * Don't install perl2web in the man dir, but only in the doc dir - (closes: bug#113911, bug#103443, bug#101100). - - -- Paolo Molaro <lupus@debian.org> Sun, 11 Nov 2001 15:38:40 +0100 - -perltidy (20010608-1) unstable; urgency=low - - * New upstream release. - * New maintainer (Closes: bug#100250). - - -- Paolo Molaro <lupus@debian.org> Mon, 11 Jun 2001 11:54:54 +0200 - -perltidy (20010328-1) unstable; urgency=low - - * New upstream release. - * Corrected upstream email address in copyright file and manpages. - * Fixed lintian warning because of incorrect upstream changelog name. - - -- Dr. Guenter Bechly <gbechly@debian.org> Fri, 30 Mar 2001 10:57:12 +0200 - -perltidy (20010323-1) unstable; urgency=low - - * Initial Release; closes: #91927 - * Adjusted paths in Makefile and fixed $DESTDIR problems. - - -- Dr. Guenter Bechly <gbechly@debian.org> Tue, 27 Mar 2001 19:39:30 +0200 - -Local variables: -mode: debian-changelog -End: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Perl-Tidy-20130922/debian/control new/Perl-Tidy-20140711/debian/control --- old/Perl-Tidy-20130922/debian/control 2002-12-02 03:53:39.000000000 +0100 +++ new/Perl-Tidy-20140711/debian/control 1970-01-01 01:00:00.000000000 +0100 @@ -1,20 +0,0 @@ -Source: perltidy -Section: interpreters -Priority: optional -Maintainer: Steve Hancock <perltidy@users.sourceforge.net> -Build-Depends: debhelper (>= 3.0.5), perl (>= 5.6.1-7) -Standards-Version: 3.5.1 - -Package: perltidy -Architecture: all -Depends: ${perl:Depends} -Description: A Perl script indenter and reformatter - Perltidy is a Perl script which indents and reformats Perl - scripts to make them easier to read. - . - The formatting can be controlled with command line parameters. - The default parameter settings approximately follow the - suggestions in the Perl Style Guide. - . - If you write Perl scripts, or spend much time reading them, - you will probably find it useful. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Perl-Tidy-20130922/debian/copyright new/Perl-Tidy-20140711/debian/copyright --- old/Perl-Tidy-20130922/debian/copyright 2002-12-02 03:53:39.000000000 +0100 +++ new/Perl-Tidy-20140711/debian/copyright 1970-01-01 01:00:00.000000000 +0100 @@ -1,12 +0,0 @@ -This is the debian package for the Perl::Tidy module. -It was created by Aubin Paul <aubin@punknews.org> using dh-make-perl. - -This copyright info was automatically extracted from the perl module. -It may not be accurate, so you better check the module sources -if don't want to get into legal troubles. - -The upstream author is: Steve Hancock <perltidy@users.sourceforge.net> - -This program is free software; you can redistribute it and/or modify it under -the terms of the GNU General Public License Version 2, found on Debian systems -in the file /usr/share/common-licenses/GPL diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Perl-Tidy-20130922/debian/rules new/Perl-Tidy-20140711/debian/rules --- old/Perl-Tidy-20130922/debian/rules 2002-12-02 03:53:39.000000000 +0100 +++ new/Perl-Tidy-20140711/debian/rules 1970-01-01 01:00:00.000000000 +0100 @@ -1,88 +0,0 @@ -#!/usr/bin/make -f -#-*- makefile -*- -# Made with the aid of dh_make, by Craig Small -# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess. -# Some lines taken from debmake, by Christoph Lameter. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 -export DH_COMPAT=3 - -PACKAGE=$(shell dh_listpackages) - -ifndef PERL -PERL = /usr/bin/perl -endif - -ifndef DESTDIR -DESTDIR=.. -endif -TMP =`pwd`/debian/$(PACKAGE) - -build: build-stamp -build-stamp: - dh_testdir - - - # Add here commands to compile the package. - $(PERL) Makefile.PL INSTALLDIRS=vendor - $(MAKE) OPTIMIZE="-O2 -g -Wall" - - touch build-stamp - -clean: - dh_testdir - dh_testroot - rm -f build-stamp - - # Add here commands to clean up after the build process. - -$(MAKE) realclean - - dh_clean - -install: - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - - # Add here commands to install the package into debian/tmp. - #$(MAKE) install DESTDIR=`pwd`/debian/tmp - $(MAKE) install PREFIX=$(TMP)/usr - - -# Build architecture-dependent files here. -binary-arch: build install -# We have nothing to do by default. - -# Build architecture-independent files here. -binary-indep: build install -# dh_testversion - dh_testdir - dh_testroot - dh_installdocs BUGS TODO README examples/README docs/README - dh_installexamples - dh_installmenu -# dh_installemacsen -# dh_installinit - dh_installcron - dh_installman -# dh_undocumented - dh_installchangelogs CHANGES - dh_link - dh_strip - dh_compress - dh_fixperms -# dh_makeshlibs - dh_installdeb - dh_perl - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb --destdir=$(DESTDIR) - -source diff: - @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Perl-Tidy-20130922/docs/perltidy.1 new/Perl-Tidy-20140711/docs/perltidy.1 --- old/Perl-Tidy-20130922/docs/perltidy.1 2013-09-22 16:40:31.000000000 +0200 +++ new/Perl-Tidy-20140711/docs/perltidy.1 2014-07-11 13:16:50.000000000 +0200 @@ -124,7 +124,7 @@ .\" ======================================================================== .\" .IX Title "PERLTIDY 1" -.TH PERLTIDY 1 "2013-09-22" "perl v5.14.2" "User Contributed Perl Documentation" +.TH PERLTIDY 1 "2014-07-11" "perl v5.14.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -617,10 +617,10 @@ exactly what flags were passed to perl. .IP "\fB\-io\fR, \fB\-\-indent\-only\fR" 4 .IX Item "-io, --indent-only" -This flag is used to deactivate all formatting and line break changes +This flag is used to deactivate all whitespace and line break changes within non-blank lines of code. When it is in effect, the only change to the script will be -to the indentation and blank lines. +to the indentation and to the number of blank lines. And any flags controlling whitespace and newlines will be ignored. You might want to use this if you are perfectly happy with your whitespace and line breaks, and merely want perltidy to handle the indentation. @@ -633,6 +633,11 @@ .Sp If you also want to keep your existing blank lines exactly as they are, you can add \fB\-\-freeze\-blank\-lines\fR. +.Sp +With this option perltidy is still free to modify the indenting (and +outdenting) of code and comments as it normally would. If you also want to +prevent long comment lines from being outdented, you can add either \fB\-noll\fR or +\&\fB\-l=0\fR. .IP "\fB\-ole=s\fR, \fB\-\-output\-line\-ending=s\fR" 4 .IX Item "-ole=s, --output-line-ending=s" where s=\f(CW\*(C`win\*(C'\fR, \f(CW\*(C`dos\*(C'\fR, \f(CW\*(C`unix\*(C'\fR, or \f(CW\*(C`mac\*(C'\fR. This flag tells perltidy @@ -2675,8 +2680,8 @@ .Ve .Sp where \fBnewword\fR is the abbreviation, and \fBopt1\fR, etc, are existing parameters -\&\fIor other abbreviations\fR. The main syntax requirement is that -the new abbreviation must begin on a new line. +\&\fIor other abbreviations\fR. The main syntax requirement is that the new +abbreviation along with its opening curly brace must begin on a new line. Space before and after the curly braces is optional. For a specific example, the following line @@ -3183,7 +3188,7 @@ \&\fIperlstyle\fR\|(1), \fIPerl::Tidy\fR\|(3) .SH "VERSION" .IX Header "VERSION" -This man page documents perltidy version 20130922. +This man page documents perltidy version 20140711. .SH "CREDITS" .IX Header "CREDITS" Michael Cartmell supplied code for adaptation to \s-1VMS\s0 and helped with diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Perl-Tidy-20130922/lib/Perl/Tidy.pm new/Perl-Tidy-20140711/lib/Perl/Tidy.pm --- old/Perl-Tidy-20130922/lib/Perl/Tidy.pm 2013-09-22 16:42:59.000000000 +0200 +++ new/Perl-Tidy-20140711/lib/Perl/Tidy.pm 2014-07-11 13:15:31.000000000 +0200 @@ -3,7 +3,7 @@ # # perltidy - a perl script indenter and formatter # -# Copyright (c) 2000-2013 by Steve Hancock +# Copyright (c) 2000-2014 by Steve Hancock # Distributed under the GPL license agreement; see file COPYING # # This program is free software; you can redistribute it and/or modify @@ -76,9 +76,10 @@ use IO::File; use File::Basename; use File::Copy; +use File::Temp qw(tempfile); BEGIN { - ( $VERSION = q($Id: Tidy.pm,v 1.74 2013/09/22 13:56:49 perltidy Exp $) ) =~ s/^.*\s+(\d+)\/(\d+)\/(\d+).*$/$1$2$3/; # all one line for MakeMaker + ( $VERSION = q($Id: Tidy.pm,v 1.74 2014/07/11 13:56:49 perltidy Exp $) ) =~ s/^.*\s+(\d+)\/(\d+)\/(\d+).*$/$1$2$3/; # all one line for MakeMaker } sub streamhandle { @@ -235,36 +236,6 @@ return undef; } -sub make_temporary_filename { - - # Make a temporary filename. - # The POSIX tmpnam() function has been unreliable for non-unix systems - # (at least for the win32 systems that I've tested), so use a pre-defined - # name for them. A disadvantage of this is that two perltidy - # runs in the same working directory may conflict. However, the chance of - # that is small and manageable by the user, especially on systems for which - # the POSIX tmpnam function doesn't work. - my $name = "perltidy.TMP"; - if ( $^O =~ /win32|dos/i || $^O eq 'VMS' || $^O eq 'MacOs' ) { - return $name; - } - eval "use POSIX qw(tmpnam)"; - if ($@) { return $name } - use IO::File; - - # just make a couple of tries before giving up and using the default - for ( 0 .. 3 ) { - my $tmpname = tmpnam(); - my $fh = IO::File->new( $tmpname, O_RDWR | O_CREAT | O_EXCL ); - if ($fh) { - $fh->close(); - return ($tmpname); - last; - } - } - return ($name); -} - # Here is a map of the flow of data from the input source to the output # line sink: # @@ -488,16 +459,17 @@ #--------------------------------------------------------------- # get command line options #--------------------------------------------------------------- - my ( - $rOpts, $config_file, $rraw_options, - $saw_extrude, $saw_pbp, $roption_string, - $rexpansion, $roption_category, $roption_range - ) + my ( $rOpts, $config_file, $rraw_options, $roption_string, + $rexpansion, $roption_category, $roption_range ) = process_command_line( $perltidyrc_stream, $is_Windows, $Windows_type, $rpending_complaint, $dump_options_type, ); + my $saw_extrude = ( grep m/^-extrude$/, @$rraw_options ) ? 1 : 0; + my $saw_pbp = + ( grep m/^-(pbp|perl-best-practices)$/, @$rraw_options ) ? 1 : 0; + #--------------------------------------------------------------- # Handle requests to dump information #--------------------------------------------------------------- @@ -621,30 +593,32 @@ my $in_place_modify = $rOpts->{'backup-and-modify-in-place'} && $rOpts->{'format'} eq 'tidy'; - # turn off -b with warnings in case of conflicts with other options + # Turn off -b with warnings in case of conflicts with other options. + # NOTE: Do this silently, without warnings, if there is a source or + # destination stream, or standard output is used. This is because the -b + # flag may have been in a .perltidyrc file and warnings break + # Test::NoWarnings. See email discussion with Merijn Brand 26 Feb 2014. if ($in_place_modify) { if ( $rOpts->{'standard-output'} ) { - my $msg = "Ignoring -b; you may not use -b and -st together"; - $msg .= " (-pbp contains -st; see manual)" if ($saw_pbp); - Warn "$msg\n"; +## my $msg = "Ignoring -b; you may not use -b and -st together"; +## $msg .= " (-pbp contains -st; see manual)" if ($saw_pbp); +## Warn "$msg\n"; $in_place_modify = 0; } if ($destination_stream) { - Warn -"Ignoring -b; you may not specify a destination stream and -b together\n"; + ##Warn "Ignoring -b; you may not specify a destination stream and -b together\n"; $in_place_modify = 0; } if ( ref($source_stream) ) { - Warn -"Ignoring -b; you may not specify a source array and -b together\n"; + ##Warn "Ignoring -b; you may not specify a source array and -b together\n"; $in_place_modify = 0; } if ( $rOpts->{'outfile'} ) { - Warn "Ignoring -b; you may not use -b and -o together\n"; + ##Warn "Ignoring -b; you may not use -b and -o together\n"; $in_place_modify = 0; } if ( defined( $rOpts->{'output-path'} ) ) { - Warn "Ignoring -b; you may not use -b and -opath together\n"; + ##Warn "Ignoring -b; you may not use -b and -opath together\n"; $in_place_modify = 0; } } @@ -709,6 +683,13 @@ #--------------------------------------------------------------- if ($source_stream) { $fileroot = "perltidy"; + + # If the source is from an array or string, then .LOG output + # is only possible if a logfile stream is specified. This prevents + # unexpected perltidy.LOG files. + if ( !defined($logfile_stream) ) { + $logfile_stream = Perl::Tidy::DevNull->new(); + } } elsif ( $input_file eq '-' ) { # '-' indicates input from STDIN $fileroot = "perltidy"; # root name to use for .ERR, .LOG, etc @@ -1324,12 +1305,7 @@ my ( $fh_stream, $fh_name ) = Perl::Tidy::streamhandle( $stream, 'r' ); if ($fh_stream) { - my ( $fout, $tmpnam ); - - # TODO: fix the tmpnam routine to return an open filehandle - $tmpnam = Perl::Tidy::make_temporary_filename(); - $fout = IO::File->new( $tmpnam, 'w' ); - + my ( $fout, $tmpnam ) = tempfile(); if ($fout) { $fname = $tmpnam; $is_tmpfile = 1; @@ -2189,8 +2165,6 @@ my @raw_options = (); my $config_file = ""; my $saw_ignore_profile = 0; - my $saw_extrude = 0; - my $saw_pbp = 0; my $saw_dump_profile = 0; my $i; @@ -2239,12 +2213,6 @@ elsif ( $i =~ /^-(pro|profile)=?$/ ) { Die "usage: -pro=filename or --profile=filename, no spaces\n"; } - elsif ( $i =~ /^-extrude$/ ) { - $saw_extrude = 1; - } - elsif ( $i =~ /^-(pbp|perl-best-practices)$/ ) { - $saw_pbp = 1; - } elsif ( $i =~ /^-(help|h|HELP|H|\?)$/ ) { usage(); Exit 0; @@ -2324,10 +2292,9 @@ if ($fh_config) { - my ( $rconfig_list, $death_message, $_saw_pbp ) = + my ( $rconfig_list, $death_message ) = read_config_file( $fh_config, $config_file, $rexpansion ); Die $death_message if ($death_message); - $saw_pbp ||= $_saw_pbp; # process any .perltidyrc parameters right now so we can # localize errors @@ -2405,12 +2372,9 @@ Die "Error on command line; for help try 'perltidy -h'\n"; } - return ( - \%Opts, $config_file, \@raw_options, - $saw_extrude, $saw_pbp, $roption_string, - $rexpansion, $roption_category, $roption_range - ); -} # end of process_command_line + return ( \%Opts, $config_file, \@raw_options, $roption_string, + $rexpansion, $roption_category, $roption_range ); +} # end of _process_command_line sub check_options { @@ -2516,23 +2480,11 @@ } } - # see if user set a non-negative logfile-gap + # setting a non-negative logfile gap causes logfile to be saved if ( defined( $rOpts->{'logfile-gap'} ) && $rOpts->{'logfile-gap'} >= 0 ) { - - # a zero gap will be taken as a 1 - if ( $rOpts->{'logfile-gap'} == 0 ) { - $rOpts->{'logfile-gap'} = 1; - } - - # setting a non-negative logfile gap causes logfile to be saved $rOpts->{'logfile'} = 1; } - # not setting logfile gap, or setting it negative, causes default of 50 - else { - $rOpts->{'logfile-gap'} = 50; - } - # set short-cut flag when only indentation is to be done. # Note that the user may or may not have already set the # indent-only flag. @@ -3042,13 +2994,13 @@ my ( $fh, $config_file, $rexpansion ) = @_; my @config_list = (); - my $saw_pbp; # file is bad if non-empty $death_message is returned my $death_message = ""; my $name = undef; my $line_no; + my $opening_brace_line; while ( my $line = $fh->getline() ) { $line_no++; chomp $line; @@ -3059,69 +3011,86 @@ $line =~ s/^\s*(.*?)\s*$/$1/; # trim both ends next unless $line; - # look for something of the general form - # newname { body } - # or just - # body - my $body = $line; - my ($newname); - if ( $line =~ /^((\w+)\s*\{)(.*)\}$/ ) { - ( $newname, $body ) = ( $2, $3, ); - } - if ($body) { + my $newname; - if ( !$saw_pbp && $body =~ /-(pbp|perl-best-practices)/ ) { - $saw_pbp = 1; - } + # Look for complete or partial abbreviation definition of the form + # name { body } or name { or name { body + # See rules in perltidy's perldoc page + # Section: Other Controls - Creating a new abbreviation + if ( $line =~ /^((\w+)\s*\{)(.*)?$/ ) { + my $oldname = $name; + ( $name, $body ) = ( $2, $3 ); + + # Cannot start new abbreviation unless old abbreviation is complete + last if ($opening_brace_line); + + $opening_brace_line = $line_no unless ( $body && $body =~ s/\}$// ); # handle a new alias definition - if ($newname) { - if ($name) { - $death_message = -"No '}' seen after $name and before $newname in config file $config_file line $.\n"; - last; - } - $name = $newname; + if ( ${$rexpansion}{$name} ) { + local $" = ')('; + my @names = sort keys %$rexpansion; + $death_message = + "Here is a list of all installed aliases\n(@names)\n" + . "Attempting to redefine alias ($name) in config file $config_file line $.\n"; + last; + } + ${$rexpansion}{$name} = []; + } - if ( ${$rexpansion}{$name} ) { - local $" = ')('; - my @names = sort keys %$rexpansion; - $death_message = - "Here is a list of all installed aliases\n(@names)\n" - . "Attempting to redefine alias ($name) in config file $config_file line $.\n"; - last; - } - ${$rexpansion}{$name} = []; + # leading opening braces not allowed + elsif ( $line =~ /^{/ ) { + $opening_brace_line = undef; + $death_message = + "Unexpected '{' at line $line_no in config file '$config_file'\n"; + last; + } + + # Look for abbreviation closing: body } or } + elsif ( $line =~ /^(.*)?\}$/ ) { + $body = $1; + if ($opening_brace_line) { + $opening_brace_line = undef; + } + else { + $death_message = +"Unexpected '}' at line $line_no in config file '$config_file'\n"; + last; } + } - # now do the body - if ($body) { + # Now store any parameters + if ($body) { - my ( $rbody_parts, $msg ) = parse_args($body); - if ($msg) { - $death_message = <<EOM; + my ( $rbody_parts, $msg ) = parse_args($body); + if ($msg) { + $death_message = <<EOM; Error reading file '$config_file' at line number $line_no. $msg Please fix this line or use -npro to avoid reading this file EOM - last; - } + last; + } - if ($name) { + if ($name) { - # remove leading dashes if this is an alias - foreach (@$rbody_parts) { s/^\-+//; } - push @{ ${$rexpansion}{$name} }, @$rbody_parts; - } - else { - push( @config_list, @$rbody_parts ); - } + # remove leading dashes if this is an alias + foreach (@$rbody_parts) { s/^\-+//; } + push @{ ${$rexpansion}{$name} }, @$rbody_parts; + } + else { + push( @config_list, @$rbody_parts ); } } } + + if ($opening_brace_line) { + $death_message = +"Didn't see a '}' to match the '{' at line $opening_brace_line in config file '$config_file'\n"; + } eval { $fh->close() }; - return ( \@config_list, $death_message, $saw_pbp ); + return ( \@config_list, $death_message ); } sub strip_comment { @@ -3337,7 +3306,7 @@ print STDOUT <<"EOM"; This is perltidy, v$VERSION -Copyright 2000-2013, Steve Hancock +Copyright 2000-2014, Steve Hancock Perltidy is free software and may be copied under the terms of the GNU General Public License, which is included in the distribution files. @@ -4114,8 +4083,15 @@ if ( -e $warning_file ) { unlink($warning_file) } } + my $logfile_gap = + defined( $rOpts->{'logfile-gap'} ) + ? $rOpts->{'logfile-gap'} + : 50; + if ( $logfile_gap == 0 ) { $logfile_gap = 1 } + bless { _log_file => $log_file, + _logfile_gap => $logfile_gap, _rOpts => $rOpts, _fh_warnings => $fh_warnings, _last_input_line_written => 0, @@ -4194,7 +4170,7 @@ if ( ( ( $input_line_number - $last_input_line_written ) >= - $rOpts->{'logfile-gap'} + $self->{_logfile_gap} ) || ( $input_line =~ /^\s*(sub|package)\s+(\w+)/ ) ) @@ -4387,6 +4363,7 @@ if ( $self->get_use_prefix() > 0 ) { my $input_line_number = Perl::Tidy::Tokenizer::get_input_line_number(); + if ( !defined($input_line_number) ) { $input_line_number = -1 } $fh_warnings->print("$input_line_number:\t@_"); $self->write_logfile_entry("WARNING: @_"); } @@ -4509,7 +4486,7 @@ } if ( $self->{_saw_brace_error} - && ( $rOpts->{'logfile-gap'} > 1 || !$save_logfile ) ) + && ( $self->{_logfile_gap} > 1 || !$save_logfile ) ) { $self->warning("To save a full .LOG file rerun with -g\n"); } @@ -5157,16 +5134,7 @@ } # Pod::Html requires a real temporary filename - # If we are making a frame, we have a name available - # Otherwise, we have to fine one - my $tmpfile; - if ( $rOpts->{'frames'} ) { - $tmpfile = $self->{_toc_filename}; - } - else { - $tmpfile = Perl::Tidy::make_temporary_filename(); - } - my $fh_tmp = IO::File->new( $tmpfile, 'w' ); + my ( $fh_tmp, $tmpfile ) = tempfile(); unless ($fh_tmp) { Perl::Tidy::Warn "unable to open temporary file $tmpfile; cannot use pod2html\n"; @@ -6146,6 +6114,7 @@ %is_assignment %is_chain_operator %is_if_unless_and_or_last_next_redo_return + %ok_to_add_semicolon_for_block_type @has_broken_sublist @dont_align @@ -6301,6 +6270,20 @@ unless while until for foreach given when default); @is_block_without_semicolon{@_} = (1) x scalar(@_); + # We will allow semicolons to be added within these block types + # as well as sub and package blocks. + # NOTES: + # 1. Note that these keywords are omitted: + # switch case given when default sort map grep + # 2. It is also ok to add for sub and package blocks and a labeled block + # 3. But not okay for other perltidy types including: + # { } ; G t + # 4. Test files: blktype.t, blktype1.t, semicolon.t + @_ = + qw( BEGIN END CHECK INIT AUTOLOAD DESTROY UNITCHECK continue if elsif else + unless do while until eval for foreach ); + @ok_to_add_semicolon_for_block_type{@_} = (1) x scalar(@_); + # 'L' is token for opening { at hash key @_ = qw" L { ( [ "; @is_opening_type{@_} = (1) x scalar(@_); @@ -9434,15 +9417,23 @@ # *VERSION = \'1.01'; # ( $VERSION ) = '$Revision: 1.74 $ ' =~ /\$Revision:\s+([^\s]+)/; # We will pass such a line straight through without breaking - # it unless -npvl is used + # it unless -npvl is used. - my $is_VERSION_statement = 0; + # Patch for problem reported in RT #81866, where files + # had been flattened into a single line and couldn't be + # tidied without -npvl. There are two parts to this patch: + # First, it is not done for a really long line (80 tokens for now). + # Second, we will only allow up to one semicolon + # before the VERSION. We need to allow at least one semicolon + # for statements like this: + # require Exporter; our $VERSION = $Exporter::VERSION; + # where both statements must be on a single line for MakeMaker - if ( - !$saw_VERSION_in_this_file - && $input_line =~ /VERSION/ # quick check to reject most lines - && $input_line =~ /([\$*])(([\w\:\']*)\bVERSION)\b.*\=/ - ) + my $is_VERSION_statement = 0; + if ( !$saw_VERSION_in_this_file + && $jmax < 80 + && $input_line =~ + /^[^;]*;?[^;]*([\$*])(([\w\:\']*)\bVERSION)\b.*\=/ ) { $saw_VERSION_in_this_file = 1; $is_VERSION_statement = 1; @@ -9839,24 +9830,14 @@ # and we don't have one && ( $last_nonblank_type ne ';' ) - # patch until some block type issues are fixed: - # Do not add semi-colon for block types '{', - # '}', and ';' because we cannot be sure yet - # that this is a block and not an anonymous - # hash (blktype.t, blktype1.t) - && ( $block_type !~ /^[\{\};]$/ ) - - # patch: and do not add semi-colons for recently - # added block types (see tmp/semicolon.t) - && ( $block_type !~ - /^(switch|case|given|when|default)$/ ) - - # it seems best not to add semicolons in these - # special block types: sort|map|grep - && ( !$is_sort_map_grep{$block_type} ) - # and we are allowed to do so. && $rOpts->{'add-semicolons'} + + # and we are allowed to for this block type + && ( $ok_to_add_semicolon_for_block_type{$block_type} + || $block_type =~ /^(sub|package)/ + || $block_type =~ /^\w+\:$/ ) + ) { @@ -12955,6 +12936,30 @@ { $adjust_indentation = 1; } + + # Patch for RT #96101, in which closing brace of anonymous subs + # was not outdented. We should look ahead and see if there is + # a level decrease at the next token (i.e., a closing token), + # but right now we do not have that information. For now + # we see if we are in a list, and this works well. + # See test files 'sub*.t' for good test cases. + elsif ($block_type_to_go[$ibeg] eq 'sub' + && $container_environment_to_go[$i_terminal] eq 'LIST' + && !$rOpts->{'indent-closing-brace'} ) + { + ( + $opening_indentation, $opening_offset, + $is_leading, $opening_exists + ) + = get_opening_indentation( $ibeg, $ri_first, $ri_last, + $rindentation_list ); + my $indentation = $leading_spaces_to_go[$ibeg]; + if ( defined($opening_indentation) + && $indentation > $opening_indentation ) + { + $adjust_indentation = 1; + } + } } # YVES patch 1 of 2: @@ -15402,9 +15407,7 @@ # 3 - ignore => # 4 - always open up if vt=0 # 5 - stable: even for one line blocks if vt=0 - if ( - !$is_long_term - ##BUBBA: TYPO && $tokens_to_go[$i_opening] =~ /^[\(\{\]L]$/ + if ( !$is_long_term && $tokens_to_go[$i_opening] =~ /^[\(\{\[]$/ && $index_before_arrow[ $depth + 1 ] > 0 && !$opening_vertical_tightness{ $tokens_to_go[$i_opening] } @@ -15826,7 +15829,18 @@ # don't break pointer calls, such as the following: # File::Spec->curdir => 1, # (This is tokenized as adjacent 'w' tokens) - if ( $tokens_to_go[ $ibreak + 1 ] !~ /^->/ ) { + ##if ( $tokens_to_go[ $ibreak + 1 ] !~ /^->/ ) { + + # And don't break before a comma, as in the following: + # ( LONGER_THAN,=> 1, + # EIGHTY_CHARACTERS,=> 2, + # CAUSES_FORMATTING,=> 3, + # LIKE_THIS,=> 4, + # ); + # This example is for -tso but should be general rule + if ( $tokens_to_go[ $ibreak + 1 ] ne '->' + && $tokens_to_go[ $ibreak + 1 ] ne ',' ) + { set_forced_breakpoint($ibreak); } } ## end if ( $types_to_go[$ibreak...]) @@ -17884,7 +17898,7 @@ && ( $iend_2 - $ibeg_2 <= 7 ) ) ); -##BUBBA: RT #81854 +##X: RT #81854 $forced_breakpoint_to_go[$iend_1] = 0 unless $old_breakpoint_to_go[$iend_1]; } @@ -22025,8 +22039,38 @@ # Start storing lines when we see a line with multiple stacked opening # tokens. - if ( $args[0] =~ /[\{\(\[]\s*[\{\(\[]$/ ) { + # patch for RT #94354, requested by Colin Williams + if ( $seqno_string =~ /^\d+(\:+\d+)+$/ && $args[0] !~ /^[\}\)\]\:\?]/ ) + { + + # This test is efficient but a little subtle: The first test says + # that we have multiple sequence numbers and hence multiple opening + # or closing tokens in this line. The second part of the test + # rejects stacked closing and ternary tokens. So if we get here + # then we should have stacked unbalanced opening tokens. + + # Here is a complex example: + + # Foo($Bar[0], { # (side comment) + # baz => 1, + # }); + + # The first line has sequence 6::4. It does not begin with + # a closing token or ternary, so it passes the test and must be + # stacked opening tokens. + + # The last line has sequence 4:6 but is a stack of closing tokens, + # so it gets rejected. + + # Note that the sequence number of an opening token for a qw quote + # is a negative number and will be rejected. + # For example, for the following line: + # skip_symbols([qw( + # $seqno_string='10:5:-1'. It would be okay to accept it but + # I decided not to do this after testing. + $valign_buffer_filling = $seqno_string; + } } } @@ -24226,6 +24270,7 @@ ';' => sub { $context = UNKNOWN_CONTEXT; $statement_type = ''; + $want_paren = ""; # /^(for|foreach)$/ if ( $is_for_foreach{ $paren_type[$paren_depth] } ) @@ -24393,12 +24438,6 @@ $block_type = code_block_type( $i_tok, $rtokens, $rtoken_type, $max_token_index ); - # remember a preceding smartmatch operator - ## SMARTMATCH - ##if ( $last_nonblank_type eq '~~' ) { - ## $block_type = $last_nonblank_type; - ##} - # patch to promote bareword type to function taking block if ( $block_type && $last_nonblank_type eq 'w' @@ -24419,6 +24458,7 @@ } } } + $brace_type[ ++$brace_depth ] = $block_type; $brace_package[$brace_depth] = $current_package; $brace_structural_type[$brace_depth] = $type; @@ -24446,8 +24486,6 @@ # propagate type information for 'do' and 'eval' blocks, and also # for smartmatch operator. This is necessary to enable us to know # if an operator or term is expected next. - ## SMARTMATCH - ##if ( $is_block_operator{$block_type} || $block_type eq '~~' ) { if ( $is_block_operator{$block_type} ) { $tok = $block_type; } @@ -25554,15 +25592,32 @@ # various quote operators elsif ( $is_q_qq_qw_qx_qr_s_y_tr_m{$tok} ) { +##NICOL PATCH if ( $expecting == OPERATOR ) { - # patch for paren-less for/foreach glitch, part 1 - # perl will accept this construct as valid: + # Be careful not to call an error for a qw quote + # where a parenthesized list is allowed. For example, + # it could also be a for/foreach construct such as # # foreach my $key qw\Uno Due Tres Quadro\ { # print "Set $key\n"; # } - unless ( $tok eq 'qw' && $is_for_foreach{$want_paren} ) + # + + # Or it could be a function call. + # NOTE: Braces in something like &{ xxx } are not + # marked as a block, we might have a method call. + # &method(...), $method->(..), &{method}(...), + # $ref[2](list) is ok & short for $ref[2]->(list) + # + # See notes in 'sub code_block_type' and + # 'sub is_non_structural_brace' + + unless ( + $tok eq 'qw' + && ( $last_nonblank_token =~ /^([\]\}\&]|\-\>)/ + || $is_for_foreach{$want_paren} ) + ) { error_if_expecting_OPERATOR(); } @@ -26819,9 +26874,10 @@ # NOTE: braces after type characters start code blocks, but for # simplicity these are not identified as such. See also # sub is_non_structural_brace. - # elsif ( $last_nonblank_type eq 't' ) { - # return $last_nonblank_token; - # } + +## elsif ( $last_nonblank_type eq 't' ) { +## return $last_nonblank_token; +## } # brace after label: elsif ( $last_nonblank_type eq 'J' ) { @@ -26870,6 +26926,27 @@ $max_token_index ); } + # Patch for bug # RT #94338 reported by Daniel Trizen + # for-loop in a parenthesized block-map triggering an error message: + # map( { foreach my $item ( '0', '1' ) { print $item} } qw(a b c) ); + # Check for a code block within a parenthesized function call + elsif ( $last_nonblank_token eq '(' ) { + my $paren_type = $paren_type[$paren_depth]; + if ( $paren_type && $paren_type =~ /^(map|grep|sort)$/ ) { + + # We will mark this as a code block but use type 't' instead + # of the name of the contining function. This will allow for + # correct parsing but will usually produce better formatting. + # Braces with block type 't' are not broken open automatically + # in the formatter as are other code block types, and this usually + # works best. + return 't'; # (Not $paren_type) + } + else { + return ""; + } + } + # anything else must be anonymous hash reference else { return ""; @@ -26880,6 +26957,7 @@ # USES GLOBAL VARIABLES: $last_nonblank_token my ( $i, $rtokens, $rtoken_type, $max_token_index ) = @_; + my ( $next_nonblank_token, $i_next ) = find_next_nonblank_token( $i, $rtokens, $max_token_index ); @@ -26917,8 +26995,14 @@ # We are only going to look ahead one more (nonblank/comment) line. # Strange formatting could cause a bad guess, but that's unlikely. - my @pre_types = @$rtoken_type[ $i + 1 .. $max_token_index ]; - my @pre_tokens = @$rtokens[ $i + 1 .. $max_token_index ]; + my @pre_types; + my @pre_tokens; + + # Ignore the rest of this line if it is a side comment + if ( $next_nonblank_token ne '#' ) { + @pre_types = @$rtoken_type[ $i + 1 .. $max_token_index ]; + @pre_tokens = @$rtokens[ $i + 1 .. $max_token_index ]; + } my ( $rpre_tokens, $rpre_types ) = peek_ahead_for_n_nonblank_pre_tokens(20); # 20 is arbitrary but # generous, and prevents @@ -26931,6 +27015,7 @@ # put a sentinel token to simplify stopping the search push @pre_types, '}'; + push @pre_types, '}'; my $jbeg = 0; $jbeg = 1 if $pre_types[0] eq 'b'; @@ -26957,9 +27042,7 @@ $j++; } elsif ( $pre_types[$j] eq 'w' ) { - unless ( $is_keyword{ $pre_tokens[$j] } ) { - $j++; - } + $j++; } elsif ( $pre_types[$j] eq '-' && $pre_types[ ++$j ] eq 'w' ) { $j++; @@ -26968,9 +27051,18 @@ $j++ if $pre_types[$j] eq 'b'; - # it's a hash ref if a comma or => follow next - if ( $pre_types[$j] eq ',' - || ( $pre_types[$j] eq '=' && $pre_types[ ++$j ] eq '>' ) ) + # Patched for RT #95708 + if ( + + # it is a comma which is not a pattern delimeter except for qw + ( + $pre_types[$j] eq ',' + && $pre_tokens[$jbeg] !~ /^(s|m|y|tr|qr|q|qq|qx)$/ + ) + + # or a => + || ( $pre_types[$j] eq '=' && $pre_types[ ++$j ] eq '>' ) + ) { $code_block_type = ""; } @@ -27038,7 +27130,8 @@ # NOTE: braces after type characters start code blocks, but for # simplicity these are not identified as such. See also # sub code_block_type - # if ($last_nonblank_type eq 't') {return 0} + + ##if ($last_nonblank_type eq 't') {return 0} # otherwise, it is non-structural if it is decorated # by type information. @@ -28058,6 +28151,11 @@ last; } } + + # POSTDEFREF ->@ ->% ->& ->* + elsif ( ( $tok =~ /^[\@\%\&\*]$/ ) && $identifier =~ /\-\>$/ ) { + $identifier .= $tok; + } elsif ( $tok =~ /^[A-Za-z_]/ ) { # alphanumeric .. $saw_alpha = 1; $id_scan_state = ':'; # now need :: @@ -28085,7 +28183,9 @@ $id_scan_state = 'A'; $identifier .= $tok; } - elsif ( ( $tok eq '#' ) && ( $identifier eq '$' ) ) { # $#array + + # $# and POSTDEFREF ->$# + elsif ( ( $tok eq '#' ) && ( $identifier =~ /\$$/ ) ) { # $#array $identifier .= $tok; # keep same state, a $ could follow } elsif ( $tok eq '{' ) { @@ -28180,6 +28280,11 @@ $identifier .= $tok; } + # POSTDEFREF: Postfix reference ->$* ->%* ->@* ->** ->&* ->$#* + elsif ( $tok eq '*' && $identifier =~ /([\@\%\$\*\&]|\$\#)$/ ) { + $identifier .= $tok; + } + elsif ( $identifier eq '$#' ) { if ( $tok eq '{' ) { $type = 'i'; $i = $i_save } @@ -30096,4 +30201,3 @@ } 1; __END__ - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Perl-Tidy-20130922/lib/Perl/Tidy.pod new/Perl-Tidy-20140711/lib/Perl/Tidy.pod --- old/Perl-Tidy-20130922/lib/Perl/Tidy.pod 2013-09-22 16:35:15.000000000 +0200 +++ new/Perl-Tidy-20140711/lib/Perl/Tidy.pod 2014-07-11 13:12:22.000000000 +0200 @@ -111,11 +111,10 @@ =item logfile -The B<logfile> parameter allows the calling program to capture -the stream that would otherwise go to a .LOG file. This -stream is only created if requested with a B<-g> parameter. It -contains detailed diagnostic information about a script -which may be useful for debugging. +The B<logfile> parameter allows the calling program to capture the log stream. +This stream is only created if requested with a B<-g> parameter. It contains +detailed diagnostic information about a script which may be useful for +debugging. =item argv @@ -416,7 +415,7 @@ =head1 VERSION -This man page documents Perl::Tidy version 20130922. +This man page documents Perl::Tidy version 20140711. =head1 LICENSE -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org