]> git.donarmstrong.com Git - perltidy.git/commitdiff
Imported Upstream version 20140328
authorDon Armstrong <don@donarmstrong.com>
Tue, 8 Apr 2014 01:13:59 +0000 (18:13 -0700)
committerDon Armstrong <don@donarmstrong.com>
Tue, 8 Apr 2014 01:13:59 +0000 (18:13 -0700)
14 files changed:
BUGS
CHANGES
MANIFEST
META.yml
Makefile.PL
TODO
bin/perltidy
debian/changelog [deleted file]
debian/control [deleted file]
debian/copyright [deleted file]
debian/rules [deleted file]
docs/perltidy.1
lib/Perl/Tidy.pm
lib/Perl/Tidy.pod

diff --git a/BUGS b/BUGS
index d43b28e19677075997b148affa7bc4ab2362c299..d7cdc37f8241e9fcd674031ea03eccd612bfa868 100644 (file)
--- a/BUGS
+++ b/BUGS
@@ -30,6 +30,9 @@ Perltidy open BUGS and LIMITATIONS
     correctly.
 
   Perltidy does not handle UTF-8 encoded files
     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
   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 --git a/CHANGES b/CHANGES
index 1ce55744794f4403b219950738ac414232631e1e..348c11caaec8b7a2b981325f14cabd15ac809e54 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,24 @@
 Perltidy Change Log
 Perltidy Change Log
+  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.
 
   2013 09 22
       - Fixed RT #88020. --converge was not working with wide characters.
 
index 6dcbc4c014b14a5c15568d2fe5f5848f153e9fc5..61cc4fa9d487b9bf4bc3f8f6c3fdfc20a816c346 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -8,10 +8,6 @@ Makefile.npm
 README
 TODO
 bin/perltidy
 README
 TODO
 bin/perltidy
-debian/changelog
-debian/control
-debian/copyright
-debian/rules
 docs/README
 docs/perltidy.1
 docs/stylekey.pod
 docs/README
 docs/perltidy.1
 docs/stylekey.pod
index 8db6b791b63958707b75f4908fc692c429de6216..aa505923a2e9c183ce4c6308fa61414435c69f4b 100644 (file)
--- a/META.yml
+++ b/META.yml
@@ -1,10 +1,10 @@
 --- #YAML:1.0
 name:               Perl-Tidy
 --- #YAML:1.0
 name:               Perl-Tidy
-version:            20130922
+version:            20140328
 abstract:           indent and reformat perl scripts
 author:
     - Steve Hancock <perltidy@perltidy.sourceforge.net>
 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
 distribution_type:  module
 configure_requires:
     ExtUtils::MakeMaker:  0
index dc8474f3d860e7b4286ec90c24bbe702b6853949..968a70a12cc643a7069f8e0860e836678b67ad55 100644 (file)
@@ -14,6 +14,7 @@ VERSION_FROM => "lib/Perl/Tidy.pm",
   $] >= 5.005
 ? (
   ABSTRACT => 'indent and reformat perl scripts',
   $] >= 5.005
 ? (
   ABSTRACT => 'indent and reformat perl scripts',
+  LICENSE => 'GPL-2.0+',
 AUTHOR => 'Steve Hancock <perltidy@perltidy.sourceforge.net>'
   )
 : ()
 AUTHOR => 'Steve Hancock <perltidy@perltidy.sourceforge.net>'
   )
 : ()
diff --git a/TODO b/TODO
index 4c33354d09e8d27408231f073fc4a67ec867b0b5..6988c5bc2490d4414ef2114225a2af9926cc027d 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,17 +1,9 @@
 Perltidy TODO List
   This is a partial "wish-list" of features to add and things to do.
 
 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.
 
   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.
   Documentation
     A FAQ is needed to explain some of the more subtle formatting issues,
     and to give examples of different styles.
index 08097638caec02ddc37d92b958d91e0fdb7e6f0f..7800565db3944888112636a9ed1ed701f257b48b 100755 (executable)
@@ -3093,7 +3093,7 @@ perlstyle(1), Perl::Tidy(3)
 
 =head1 VERSION
 
 
 =head1 VERSION
 
-This man page documents perltidy version 20130922.
+This man page documents perltidy version 20140328.
 
 =head1 CREDITS
 
 
 =head1 CREDITS
 
diff --git a/debian/changelog b/debian/changelog
deleted file mode 100644 (file)
index 01d65c8..0000000
+++ /dev/null
@@ -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 --git a/debian/control b/debian/control
deleted file mode 100644 (file)
index 5107fe8..0000000
+++ /dev/null
@@ -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 --git a/debian/copyright b/debian/copyright
deleted file mode 100644 (file)
index 8cc9b9d..0000000
+++ /dev/null
@@ -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 --git a/debian/rules b/debian/rules
deleted file mode 100755 (executable)
index f6289a7..0000000
+++ /dev/null
@@ -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
index feed5e11d89bbac1c7097d12668a660e29e08a8c..4ad6877d11d25d734e64ddb48392e556ea3ca9eb 100644 (file)
 .\" ========================================================================
 .\"
 .IX Title "PERLTIDY 1"
 .\" ========================================================================
 .\"
 .IX Title "PERLTIDY 1"
-.TH PERLTIDY 1 "2013-09-22" "perl v5.14.2" "User Contributed Perl Documentation"
+.TH PERLTIDY 1 "2014-03-27" "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
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -3183,7 +3183,7 @@ purpose of this rule is to prevent generating confusing filenames such as
 \&\fIperlstyle\fR\|(1), \fIPerl::Tidy\fR\|(3)
 .SH "VERSION"
 .IX Header "VERSION"
 \&\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 20140328.
 .SH "CREDITS"
 .IX Header "CREDITS"
 Michael Cartmell supplied code for adaptation to \s-1VMS\s0 and helped with
 .SH "CREDITS"
 .IX Header "CREDITS"
 Michael Cartmell supplied code for adaptation to \s-1VMS\s0 and helped with
index 1d55572125eb5791da328a1e267d28bce00697a8..c326a8f69718f15df1c444dc625708e87df6c73e 100644 (file)
@@ -3,7 +3,7 @@
 #
 #    perltidy - a perl script indenter and formatter
 #
 #
 #    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
 #    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 Cwd;
 use IO::File;
 use File::Basename;
 use File::Copy;
 use IO::File;
 use File::Basename;
 use File::Copy;
+use File::Temp qw(tempfile);
 
 BEGIN {
 
 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/03/28 13:56:49 perltidy Exp $) ) =~ s/^.*\s+(\d+)\/(\d+)\/(\d+).*$/$1$2$3/; # all one line for MakeMaker
 }
 
 sub streamhandle {
 }
 
 sub streamhandle {
@@ -235,36 +236,6 @@ sub catfile {
     return undef;
 }
 
     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:
 #
 # Here is a map of the flow of data from the input source to the output
 # line sink:
 #
@@ -621,30 +592,32 @@ EOM
     my $in_place_modify = $rOpts->{'backup-and-modify-in-place'}
       && $rOpts->{'format'} eq 'tidy';
 
     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'} ) {
     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) {
             $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) ) {
             $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'} ) {
             $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'} ) ) {
             $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;
         }
     }
             $in_place_modify = 0;
         }
     }
@@ -709,6 +682,13 @@ EOM
         #---------------------------------------------------------------
         if ($source_stream) {
             $fileroot = "perltidy";
         #---------------------------------------------------------------
         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
         }
         elsif ( $input_file eq '-' ) {    # '-' indicates input from STDIN
             $fileroot = "perltidy";       # root name to use for .ERR, .LOG, etc
@@ -1324,12 +1304,7 @@ sub get_stream_as_named_file {
             my ( $fh_stream, $fh_name ) =
               Perl::Tidy::streamhandle( $stream, 'r' );
             if ($fh_stream) {
             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;
                 if ($fout) {
                     $fname      = $tmpnam;
                     $is_tmpfile = 1;
@@ -2516,23 +2491,11 @@ sub check_options {
         }
     }
 
         }
     }
 
-    # 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 ) {
     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;
     }
 
         $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.
     # 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.
@@ -3337,7 +3300,7 @@ sub show_version {
     print STDOUT <<"EOM";
 This is perltidy, v$VERSION 
 
     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.
 
 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 +4077,15 @@ sub new {
         if ( -e $warning_file ) { unlink($warning_file) }
     }
 
         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,
     bless {
         _log_file                      => $log_file,
+        _logfile_gap                   => $logfile_gap,
         _rOpts                         => $rOpts,
         _fh_warnings                   => $fh_warnings,
         _last_input_line_written       => 0,
         _rOpts                         => $rOpts,
         _fh_warnings                   => $fh_warnings,
         _last_input_line_written       => 0,
@@ -4194,7 +4164,7 @@ sub black_box {
     if (
         (
             ( $input_line_number - $last_input_line_written ) >=
     if (
         (
             ( $input_line_number - $last_input_line_written ) >=
-            $rOpts->{'logfile-gap'}
+            $self->{_logfile_gap}
         )
         || ( $input_line =~ /^\s*(sub|package)\s+(\w+)/ )
       )
         )
         || ( $input_line =~ /^\s*(sub|package)\s+(\w+)/ )
       )
@@ -4387,6 +4357,7 @@ sub warning {
             if ( $self->get_use_prefix() > 0 ) {
                 my $input_line_number =
                   Perl::Tidy::Tokenizer::get_input_line_number();
             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: @_");
             }
                 $fh_warnings->print("$input_line_number:\t@_");
                 $self->write_logfile_entry("WARNING: @_");
             }
@@ -4509,7 +4480,7 @@ sub finish {
         }
 
         if ( $self->{_saw_brace_error}
         }
 
         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");
         }
         {
             $self->warning("To save a full .LOG file rerun with -g\n");
         }
@@ -5157,16 +5128,7 @@ sub pod_to_html {
     }
 
     # Pod::Html requires a real temporary filename
     }
 
     # 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";
     unless ($fh_tmp) {
         Perl::Tidy::Warn
           "unable to open temporary file $tmpfile; cannot use pod2html\n";
@@ -15402,9 +15364,7 @@ sub pad_array_to_go {
                 #    3 - ignore =>
                 #    4 - always open up if vt=0
                 #    5 - stable: even for one line blocks if vt=0
                 #    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] }
                     && $tokens_to_go[$i_opening] =~ /^[\(\{\[]$/
                     && $index_before_arrow[ $depth + 1 ] > 0
                     && !$opening_vertical_tightness{ $tokens_to_go[$i_opening] }
@@ -15826,7 +15786,18 @@ sub pad_array_to_go {
                         # don't break pointer calls, such as the following:
                         #  File::Spec->curdir  => 1,
                         # (This is tokenized as adjacent 'w' tokens)
                         # 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...])
                             set_forced_breakpoint($ibreak);
                         }
                     } ## end if ( $types_to_go[$ibreak...])
@@ -17884,7 +17855,7 @@ sub undo_forced_breakpoint_stack {
                                 && ( $iend_2 - $ibeg_2 <= 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];
                     }
                         $forced_breakpoint_to_go[$iend_1] = 0
                           unless $old_breakpoint_to_go[$iend_1];
                     }
@@ -24226,6 +24197,7 @@ sub prepare_for_a_new_file {
         ';' => sub {
             $context        = UNKNOWN_CONTEXT;
             $statement_type = '';
         ';' => sub {
             $context        = UNKNOWN_CONTEXT;
             $statement_type = '';
+            $want_paren     = "";
 
             #    /^(for|foreach)$/
             if ( $is_for_foreach{ $paren_type[$paren_depth] } )
 
             #    /^(for|foreach)$/
             if ( $is_for_foreach{ $paren_type[$paren_depth] } )
@@ -25554,15 +25526,32 @@ EOM
 
                 # various quote operators
                 elsif ( $is_q_qq_qw_qx_qr_s_y_tr_m{$tok} ) {
 
                 # various quote operators
                 elsif ( $is_q_qq_qw_qx_qr_s_y_tr_m{$tok} ) {
+##NICOL PATCH
                     if ( $expecting == OPERATOR ) {
 
                     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";
                         #    }
                         #
                         #    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();
                         }
                         {
                             error_if_expecting_OPERATOR();
                         }
@@ -26819,9 +26808,10 @@ sub code_block_type {
     # NOTE: braces after type characters start code blocks, but for
     # simplicity these are not identified as such.  See also
     # sub is_non_structural_brace.
     # 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' ) {
 
     # brace after label:
     elsif ( $last_nonblank_type eq 'J' ) {
@@ -27038,7 +27028,8 @@ sub is_non_structural_brace {
     # NOTE: braces after type characters start code blocks, but for
     # simplicity these are not identified as such.  See also
     # sub code_block_type
     # 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.
 
     # otherwise, it is non-structural if it is decorated
     # by type information.
index 4a2e263f0878647945f0e4e382ea1a2a9de2aee1..54af086b1e10956b96654914071d8428e8bd6162 100644 (file)
@@ -111,11 +111,10 @@ parameter is ignored.
 
 =item logfile
 
 
 =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
 
 
 =item argv
 
@@ -416,7 +415,7 @@ to perltidy.
 
 =head1 VERSION
 
 
 =head1 VERSION
 
-This man page documents Perl::Tidy version 20130922.
+This man page documents Perl::Tidy version 20140328.
 
 =head1 LICENSE
 
 
 =head1 LICENSE