Hello community,

here is the log from the commit of package perl-Perl-Tidy for openSUSE:Factory 
checked in at 2016-03-16 10:34:02
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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    
2015-08-29 20:04:40.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.perl-Perl-Tidy.new/perl-Perl-Tidy.changes       
2016-03-16 10:34:04.000000000 +0100
@@ -1,0 +2,57 @@
+Tue Mar  8 10:48:54 UTC 2016 - [email protected]
+
+- updated to 20160302
+   see /usr/share/doc/packages/perl-Perl-Tidy/CHANGES
+
+    2016 03 02
+        - RT #112534. Corrected a minor problem in which an unwanted newline
+          was placed before the closing brace of an anonymous sub with 
+          a signature, if it was in a list.  Thanks to Dmytro Zagashev.
+  
+        - Corrected a minor problem in which occasional extra indentation was
+          given to the closing brace of an anonymous sub in a list when the 
-lp 
+          parameter was set.
+  
+    2016 03 01
+        - RT #104427. Added support for signatures.
+  
+        - RT #111512.  Changed global warning flag $^W = 1 to use warnings;
+          Thanks to Dmytro Zagashev.
+  
+        - RT #110297, added support for new regexp modifier /n
+          Thanks to Dmytro Zagashev.
+  
+        - RT #111519.  The -io (--indent-only) and -dac (--delete-all-comments)
+          can now both be used in one pass. Thanks to Dmitry Veltishev.
+  
+        - Patch to avoid error message with 'catch' used by TryCatch, as in
+             catch($err){
+                # do something
+             }
+          Thanks to Nick Tonkin.
+  
+        - RT #32905, UTF-8 coding is now more robust. Thanks to qsimpleq
+          and Dmytro for patches.
+  
+        - RT #106885. Added string bitwise operators ^. &. |. ~. ^.= &.= |.=
+   
+        - Fixed RT #107832 and #106492, lack of vertical alignment of two lines
+          when -boc flag (break at old commas) is set.  This bug was 
+          inadvertantly introduced in previous bug fix RT #98902. 
+  
+        - Some common extensions to Perl syntax are handled better.
+          In particular, the following snippet is now foratted cleanly:
+  
+            method deposit( Num $amount) {
+                $self->balance( $self->balance + $amount );
+            }
+  
+          A new flag -xs (--extended-syntax) was added to enable this, and the 
default
+          is to use -xs. 
+  
+          In previous versions, and now only when -nxs is set, this snippet of 
code
+          generates the following error message:
+  
+          "syntax error at ') {', didn't see one of: case elsif for foreach 
given if switch unless until when while"
+
+-------------------------------------------------------------------

Old:
----
  Perl-Tidy-20150815.tar.gz

New:
----
  Perl-Tidy-20160302.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ perl-Perl-Tidy.spec ++++++
--- /var/tmp/diff_new_pack.cE6ARY/_old  2016-03-16 10:34:05.000000000 +0100
+++ /var/tmp/diff_new_pack.cE6ARY/_new  2016-03-16 10:34:05.000000000 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package perl-Perl-Tidy
 #
-# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2016 SUSE LINUX 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:        20150815
+Version:        20160302
 Release:        0
 #Upstream:  This package is free software; you can redistribute it and/or 
modify it under the terms of the "GNU General Public License". Please refer to 
the file "COPYING" for details.
 %define cpan_name Perl-Tidy
@@ -46,8 +46,8 @@
 
 The call to *perltidy* returns a scalar *$error_flag* which is TRUE if an
 error caused premature termination, and FALSE if the process ran to normal
-completion. Additional discuss of errors is contained below in the the
-ERROR HANDLING manpage section.
+completion. Additional discuss of errors is contained below in the ERROR
+HANDLING section.
 
 %prep
 %setup -q -n %{cpan_name}-%{version}

++++++ Perl-Tidy-20150815.tar.gz -> Perl-Tidy-20160302.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Perl-Tidy-20150815/CHANGES 
new/Perl-Tidy-20160302/CHANGES
--- old/Perl-Tidy-20150815/CHANGES      2015-08-15 02:05:30.000000000 +0200
+++ new/Perl-Tidy-20160302/CHANGES      2016-03-01 17:00:04.000000000 +0100
@@ -1,4 +1,55 @@
 Perltidy Change Log
+  2016 03 02
+      - RT #112534. Corrected a minor problem in which an unwanted newline
+        was placed before the closing brace of an anonymous sub with 
+        a signature, if it was in a list.  Thanks to Dmytro Zagashev.
+
+      - Corrected a minor problem in which occasional extra indentation was
+        given to the closing brace of an anonymous sub in a list when the -lp 
+        parameter was set.
+
+  2016 03 01
+      - RT #104427. Added support for signatures.
+
+      - RT #111512.  Changed global warning flag $^W = 1 to use warnings;
+        Thanks to Dmytro Zagashev.
+
+      - RT #110297, added support for new regexp modifier /n
+        Thanks to Dmytro Zagashev.
+
+      - RT #111519.  The -io (--indent-only) and -dac (--delete-all-comments)
+        can now both be used in one pass. Thanks to Dmitry Veltishev.
+
+      - Patch to avoid error message with 'catch' used by TryCatch, as in
+           catch($err){
+              # do something
+           }
+        Thanks to Nick Tonkin.
+
+      - RT #32905, UTF-8 coding is now more robust. Thanks to qsimpleq
+        and Dmytro for patches.
+
+      - RT #106885. Added string bitwise operators ^. &. |. ~. ^.= &.= |.=
+ 
+      - Fixed RT #107832 and #106492, lack of vertical alignment of two lines
+        when -boc flag (break at old commas) is set.  This bug was 
+        inadvertantly introduced in previous bug fix RT #98902. 
+
+      - Some common extensions to Perl syntax are handled better.
+        In particular, the following snippet is now foratted cleanly:
+
+          method deposit( Num $amount) {
+              $self->balance( $self->balance + $amount );
+          }
+
+        A new flag -xs (--extended-syntax) was added to enable this, and the 
default
+        is to use -xs. 
+
+        In previous versions, and now only when -nxs is set, this snippet of 
code
+        generates the following error message:
+
+        "syntax error at ') {', didn't see one of: case elsif for foreach 
given if switch unless until when while"
+
   2015 08 15
       - Fixed RT# 105484, Invalid warning about 'else' in 'switch' statement.  
The
         warning happened if a 'case' statement did not use parens.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Perl-Tidy-20150815/META.yml 
new/Perl-Tidy-20160302/META.yml
--- old/Perl-Tidy-20150815/META.yml     2015-08-15 03:06:20.000000000 +0200
+++ new/Perl-Tidy-20160302/META.yml     2016-03-01 17:00:06.000000000 +0100
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:               Perl-Tidy
-version:            20150815
+version:            20160302
 abstract:           indent and reformat perl scripts
 author:
     - Steve Hancock <[email protected]>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Perl-Tidy-20150815/TODO new/Perl-Tidy-20160302/TODO
--- old/Perl-Tidy-20150815/TODO 2015-08-15 01:53:40.000000000 +0200
+++ new/Perl-Tidy-20160302/TODO 2016-02-27 01:20:14.000000000 +0100
@@ -1,7 +1,9 @@
 Perltidy TODO List
-    This is a partial "wish-list" of features to add and things to do.
+    This is a partial "wish-list" of features to add and things to do. For
+    the latest list of bugs and feature requests at CPAN see:
+
+    https://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Tidy
 
-  Automatically Detect UTF-8 Character Streams
   Improved Vertical Alignment
     There are still many opportunities for improving vertical alignment.
 
@@ -25,7 +27,13 @@
 
   Make perltidy support the syntax of module XXX
     This generally won't be done unless the module is part of the core perl
-    distribution because it is such an open-ended problem. But in some cases
-    it might be possible to use the prefilter and postfilter capabilities of
-    the Tidy.pm module may help.
+    distribution because it is such an open-ended problem. Compounding the
+    problem is the fact that perltidy often is invoked within an editor on
+    small snippets of code, so it must to work correctly without seeing any
+    particular 'use xxx' statement. Therefore, any syntax changes that
+    conflict with standard Perl syntax can't easily be handled.
+
+    However, an effort is being made to make perltidy generally more
+    tolerant of extensions to perl syntax. Also, the pre- and post-filter
+    capabilities of the Tidy.pm module may help.
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Perl-Tidy-20150815/bin/perltidy 
new/Perl-Tidy-20160302/bin/perltidy
--- old/Perl-Tidy-20150815/bin/perltidy 2015-08-15 03:06:18.000000000 +0200
+++ new/Perl-Tidy-20160302/bin/perltidy 2016-03-01 17:00:03.000000000 +0100
@@ -501,6 +501,24 @@
 add a B<-c> and B<-x> if appropriate.  The F<.LOG> file will show
 exactly what flags were passed to perl.
 
+=item B<-xs>,   B<--extended-syntax>      
+
+A problem with formatting Perl code is that some modules can introduce new
+syntax.  This flag allows perltidy to handle certain common extensions
+to the standard syntax without complaint.  
+
+For example, without this flag a structure such as the following would generate
+a syntax error and the braces would not be balanced:
+
+    method deposit( Num $amount) {
+        $self->balance( $self->balance + $amount );
+    }
+
+This flag is enabled by default but it can be deactivated with B<-nxs>.
+Probably the only reason to deactivate this flag is to generate more diagnostic
+messages when debugging a script.
+
+
 =item B<-io>,   B<--indent-only>       
 
 This flag is used to deactivate all whitespace and line break changes
@@ -525,6 +543,11 @@
 prevent long comment lines from being outdented, you can add either B<-noll> or
 B<-l=0>.
 
+Setting this flag will prevent perltidy from doing any special operations on
+closing side comments.  You may still delete all side comments however when
+this flag is in effect.
+
+
 =item B<-enc=s>,  B<--character-encoding=s>
 
 where B<s>=B<none> or B<utf8>.  This flag tells perltidy the character encoding
@@ -3116,7 +3139,7 @@
 
 =head1 VERSION
 
-This man page documents perltidy version 20150815.
+This man page documents perltidy version 20160302.
 
 =head1 CREDITS
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Perl-Tidy-20150815/docs/perltidy.1 
new/Perl-Tidy-20160302/docs/perltidy.1
--- old/Perl-Tidy-20150815/docs/perltidy.1      2015-08-15 02:45:41.000000000 
+0200
+++ new/Perl-Tidy-20160302/docs/perltidy.1      2016-03-01 15:48:30.000000000 
+0100
@@ -124,7 +124,7 @@
 .\" ========================================================================
 .\"
 .IX Title "PERLTIDY 1"
-.TH PERLTIDY 1 "2015-08-14" "perl v5.14.2" "User Contributed Perl 
Documentation"
+.TH PERLTIDY 1 "2016-03-01" "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
@@ -615,6 +615,24 @@
 Perltidy will pass your string to perl with the exception that it will
 add a \fB\-c\fR and \fB\-x\fR if appropriate.  The \fI.LOG\fR file will show
 exactly what flags were passed to perl.
+.IP "\fB\-xs\fR,   \fB\-\-extended\-syntax\fR" 4
+.IX Item "-xs,   --extended-syntax"
+A problem with formatting Perl code is that some modules can introduce new
+syntax.  This flag allows perltidy to handle certain common extensions
+to the standard syntax without complaint.
+.Sp
+For example, without this flag a structure such as the following would generate
+a syntax error and the braces would not be balanced:
+.Sp
+.Vb 3
+\&    method deposit( Num $amount) {
+\&        $self\->balance( $self\->balance + $amount );
+\&    }
+.Ve
+.Sp
+This flag is enabled by default but it can be deactivated with \fB\-nxs\fR.
+Probably the only reason to deactivate this flag is to generate more diagnostic
+messages when debugging a script.
 .IP "\fB\-io\fR,   \fB\-\-indent\-only\fR" 4
 .IX Item "-io,   --indent-only"
 This flag is used to deactivate all whitespace and line break changes
@@ -638,6 +656,10 @@
 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.
+.Sp
+Setting this flag will prevent perltidy from doing any special operations on
+closing side comments.  You may still delete all side comments however when
+this flag is in effect.
 .IP "\fB\-enc=s\fR,  \fB\-\-character\-encoding=s\fR" 4
 .IX Item "-enc=s,  --character-encoding=s"
 where \fBs\fR=\fBnone\fR or \fButf8\fR.  This flag tells perltidy the 
character encoding
@@ -3207,7 +3229,7 @@
 \&\fIperlstyle\fR\|(1), \fIPerl::Tidy\fR\|(3)
 .SH "VERSION"
 .IX Header "VERSION"
-This man page documents perltidy version 20150815.
+This man page documents perltidy version 20160302.
 .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-20150815/lib/Perl/Tidy.pm 
new/Perl-Tidy-20160302/lib/Perl/Tidy.pm
--- old/Perl-Tidy-20150815/lib/Perl/Tidy.pm     2015-08-15 02:18:51.000000000 
+0200
+++ new/Perl-Tidy-20160302/lib/Perl/Tidy.pm     2016-03-01 15:46:22.000000000 
+0100
@@ -3,7 +3,7 @@
 #
 #    perltidy - a perl script indenter and formatter
 #
-#    Copyright (c) 2000-2015 by Steve Hancock
+#    Copyright (c) 2000-2016 by Steve Hancock
 #    Distributed under the GPL license agreement; see file COPYING
 #
 #    This program is free software; you can redistribute it and/or modify
@@ -53,9 +53,11 @@
 ############################################################
 
 package Perl::Tidy;
-use 5.004;    # need IO::File from 5.004 or later
-BEGIN { $^W = 1; }    # turn on warnings
 
+# Actually should use a version later than about 5.8.5 to use
+# wide characters.
+use 5.004;    # need IO::File from 5.004 or later
+use warnings;
 use strict;
 use Exporter;
 use Carp;
@@ -74,13 +76,14 @@
 @EXPORT = qw( &perltidy );
 
 use Cwd;
+use Encode ();
 use IO::File;
 use File::Basename;
 use File::Copy;
 use File::Temp qw(tempfile);
 
 BEGIN {
-    ( $VERSION = q($Id: Tidy.pm,v 1.74 2015/08/15 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 2016/03/02 13:56:49 perltidy Exp $) ) 
=~ s/^.*\s+(\d+)\/(\d+)\/(\d+).*$/$1$2$3/; # all one line for MakeMaker
 }
 
 sub streamhandle {
@@ -173,12 +176,6 @@
     $fh = $New->( $filename, $mode )
       or Warn("Couldn't open file:$filename in mode:$mode : $!\n");
 
-    # The first call here will be to read the config file, which is before
-    # the --encoding has been set, so the config file cannot be read as utf8
-    $fh->binmode(':encoding(utf8)')
-      if ( $rOpts_character_encoding
-        && $rOpts_character_encoding eq 'utf8'
-        && $fh->can('binmode') );
     return $fh, ( $ref or $filename );
 }
 
@@ -811,12 +808,33 @@
         # Prefilters and postfilters: The prefilter is a code reference
         # that will be applied to the source before tidying, and the
         # postfilter is a code reference to the result before outputting.
-        if ($prefilter) {
+        if (
+            $prefilter
+            || (   $rOpts_character_encoding
+                && $rOpts_character_encoding eq 'utf8' )
+          )
+        {
             my $buf = '';
             while ( my $line = $source_object->get_line() ) {
                 $buf .= $line;
             }
-            $buf = $prefilter->($buf);
+
+            $buf = $prefilter->($buf) if $prefilter;
+
+            if (   $rOpts_character_encoding
+                && $rOpts_character_encoding eq 'utf8'
+                && !utf8::is_utf8($buf) )
+            {
+                eval {
+                    $buf = Encode::decode( 'UTF-8', $buf,
+                        Encode::FB_CROAK | Encode::LEAVE_SRC );
+                };
+                if ($@) {
+                    Warn
+"skipping file: $input_file: Unable to decode source as UTF-8\n";
+                    next;
+                }
+            }
 
             $source_object = Perl::Tidy::LineSource->new( \$buf, $rOpts,
                 $rpending_logfile_message );
@@ -915,9 +933,9 @@
         # Eventually all I/O may be done with binmode, but for now it is
         # only done when a user requests a particular line separator
         # through the -ple or -ole flags
-        my $binmode = 0;
-        if   ( defined($line_separator) ) { $binmode        = 1 }
-        else                              { $line_separator = "\n" }
+        my $binmode = defined($line_separator)
+          || defined($rOpts_character_encoding);
+        $line_separator = "\n" unless defined($line_separator);
 
         my ( $sink_object, $postfilter_buffer );
         if ($postfilter) {
@@ -1063,6 +1081,7 @@
                 look_for_autoloader => $rOpts->{'look-for-autoloader'},
                 look_for_selfloader => $rOpts->{'look-for-selfloader'},
                 trim_qw             => $rOpts->{'trim-qw'},
+                extended_syntax     => $rOpts->{'extended-syntax'},
 
                 continuation_indentation =>
                   $rOpts->{'continuation-indentation'},
@@ -1567,6 +1586,7 @@
     $add_option->( 'preserve-line-endings',        'ple',  '!' );
     $add_option->( 'tabs',                         't',    '!' );
     $add_option->( 'default-tabsize',              'dt',   '=i' );
+    $add_option->( 'extended-syntax',              'xs',   '!' );
 
     ########################################
     $category = 2;    # Code indentation control
@@ -1840,6 +1860,7 @@
       continuation-indentation=2
       delete-old-newlines
       delete-semicolons
+      extended-syntax
       fuzzy-line-length
       hanging-side-comments
       indent-block-comments
@@ -3328,7 +3349,7 @@
     print STDOUT <<"EOM";
 This is perltidy, v$VERSION 
 
-Copyright 2000-2015, Steve Hancock
+Copyright 2000-2016, 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.
@@ -3935,7 +3956,12 @@
         $output_file_open = 1;
         if ($binmode) {
             if ( ref($fh) eq 'IO::File' ) {
-                binmode $fh;
+                if (   $rOpts->{'character-encoding'}
+                    && $rOpts->{'character-encoding'} eq 'utf8' )
+                {
+                    binmode $fh, ":encoding(UTF-8)";
+                }
+                else { binmode $fh }
             }
             if ( $output_file eq '-' ) { binmode STDOUT }
         }
@@ -9500,10 +9526,20 @@
         # qw lines will still go out at the end of this routine.
         if ( $rOpts->{'indent-only'} ) {
             flush();
-            trim($input_line);
+            my $line = $input_line;
+
+            # delete side comments if requested with -io, but
+            # we will not allow deleting of closing side comments with -io
+            # because the coding would be more complex
+            if (   $rOpts->{'delete-side-comments'}
+                && $rtoken_type->[$jmax] eq '#' )
+            {
+                $line = join "", @{$rtokens}[ 0 .. $jmax - 1 ];
+            }
+            trim($line);
 
             extract_token(0);
-            $token                 = $input_line;
+            $token                 = $line;
             $type                  = 'q';
             $block_type            = "";
             $container_type        = "";
@@ -9568,6 +9604,8 @@
                 && $types_to_go[$max_index_to_go] eq ',' )
           )
         {
+            $forced_breakpoint_to_go[$max_index_to_go] = 1
+              if ($rOpts_break_at_old_comma_breakpoints);
             destroy_one_line_block();
             output_line_to_go();
         }
@@ -9968,7 +10006,13 @@
                     # But make a line break if the curly ends a
                     # significant block:
                     if (
-                        $is_block_without_semicolon{$block_type}
+                        (
+                            $is_block_without_semicolon{$block_type}
+
+                            # Follow users break point for
+                            # one line block types U & G, such as a 'try' block
+                            || $is_one_line_block =~ /^[UG]$/ && $j == $jmax
+                        )
 
                         # if needless semicolon follows we handle it later
                         && $next_nonblank_token ne ';'
@@ -10543,6 +10587,41 @@
         $i_start = $max_index_to_go;
     }
 
+    # the previous nonblank token should start these block types
+    elsif (( $last_last_nonblank_token_to_go eq $block_type )
+        || ( $block_type =~ /^sub/ )
+        || $block_type =~ /\(\)/ )
+    {
+        $i_start = $last_last_nonblank_index_to_go;
+
+        # Patch for signatures and extended syntax ...
+        # if the previous token was a closing paren we should walk back up to
+        # find the keyword (sub). Otherwise, we might form a one line block,
+        # which stays intact, and cause the parenthesized expression to break
+        # open.  That looks bad.
+        if ( $tokens_to_go[$i_start] eq ')' ) {
+
+            # walk back to find the first token with this level
+            # it should be the opening paren...
+            my $lev_want = $levels_to_go[$i_start];
+            for ( $i_start-- ; $i_start >= 0 ; $i_start-- ) {
+                if ( $i_start <= 0 ) { return 0 }
+                my $lev = $levels_to_go[$i_start];
+                if ( $lev <= $lev_want ) {
+
+                    # if not an opening paren then probably a syntax error
+                    if ( $tokens_to_go[$i_start] ne '(' ) { return 0 }
+
+                    # now step back to the opening keyword (sub)
+                    $i_start--;
+                    if ( $i_start > 0 && $types_to_go[$i_start] eq 'b' ) {
+                        $i_start--;
+                    }
+                }
+            }
+        }
+    }
+
     elsif ( $last_last_nonblank_token_to_go eq ')' ) {
 
         # For something like "if (xxx) {", the keyword "if" will be
@@ -10556,18 +10635,19 @@
             $i_start++;
         }
 
-        unless ( $tokens_to_go[$i_start] eq $block_type ) {
+        # Patch to avoid breaking short blocks defined with extended_syntax:
+        # Strip off any trailing () which was added in the parser to mark
+        # the opening keyword.  For example, in the following
+        #    create( TypeFoo $e) {$bubba}
+        # the blocktype would be marked as create()
+        my $stripped_block_type = $block_type;
+        $stripped_block_type =~ s/\(\)$//;
+
+        unless ( $tokens_to_go[$i_start] eq $stripped_block_type ) {
             return 0;
         }
     }
 
-    # the previous nonblank token should start these block types
-    elsif (( $last_last_nonblank_token_to_go eq $block_type )
-        || ( $block_type =~ /^sub/ ) )
-    {
-        $i_start = $last_last_nonblank_index_to_go;
-    }
-
     # patch for SWITCH/CASE to retain one-line case/when blocks
     elsif ( $block_type eq 'case' || $block_type eq 'when' ) {
 
@@ -13004,7 +13084,7 @@
                 # 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'
+                if (   $block_type_to_go[$ibeg] =~ /^sub\s*\(?/
                     && $container_environment_to_go[$i_terminal] eq 'LIST'
                     && !$rOpts->{'indent-closing-brace'} )
                 {
@@ -13016,7 +13096,8 @@
                         $rindentation_list );
                     my $indentation = $leading_spaces_to_go[$ibeg];
                     if ( defined($opening_indentation)
-                        && $indentation > $opening_indentation )
+                        && get_SPACES($indentation) >
+                        get_SPACES($opening_indentation) )
                     {
                         $adjust_indentation = 1;
                     }
@@ -13039,7 +13120,8 @@
                     $rindentation_list );
                 my $indentation = $leading_spaces_to_go[$ibeg];
                 if ( defined($opening_indentation)
-                    && $indentation > $opening_indentation )
+                    && get_SPACES($indentation) >
+                    get_SPACES($opening_indentation) )
                 {
                     $adjust_indentation = 1;
                 }
@@ -17162,6 +17244,26 @@
         @is_mult_div{@_} = (1) x scalar(@_);
     }
 
+    sub DUMP_BREAKPOINTS {
+
+        # Debug routine to dump current breakpoints...not normally called
+        # We are given indexes to the current lines:
+        # $ri_beg = ref to array of BEGinning indexes of each line
+        # $ri_end = ref to array of ENDing indexes of each line
+        my ( $ri_beg, $ri_end, $msg ) = @_;
+        print STDERR "----Dumping breakpoints from: $msg----\n";
+        for my $n ( 0 .. @{$ri_end} - 1 ) {
+            my $ibeg = $$ri_beg[$n];
+            my $iend = $$ri_end[$n];
+            my $text = "";
+            foreach my $i ( $ibeg .. $iend ) {
+                $text .= $tokens_to_go[$i];
+            }
+            print STDERR "$n ($ibeg:$iend) $text\n";
+        }
+        print STDERR "----\n";
+    }
+
     sub recombine_breakpoints {
 
         # sub set_continuation_breaks is very liberal in setting line breaks
@@ -18668,12 +18770,24 @@
                 #     }
                 # };
                 #
-                || (   $line_count
+                || (
+                       $line_count
                     && ( $token eq ')' )
                     && ( $next_nonblank_type eq '{' )
                     && ($next_nonblank_block_type)
                     && ( $next_nonblank_block_type ne $tokens_to_go[$i_begin] )
-                    && !$rOpts->{'opening-brace-always-on-right'} )
+
+                    # RT #104427: Dont break before opening sub brace because
+                    # sub block breaks handled at higher level, unless
+                    # it looks like the preceeding list is long and broken
+                    && !(
+                        $next_nonblank_block_type =~ /^sub/
+                        && ( $nesting_depth_to_go[$i_begin] ==
+                            $nesting_depth_to_go[$i_next_nonblank] )
+                    )
+
+                    && !$rOpts->{'opening-brace-always-on-right'}
+                )
 
                 # There is an implied forced break at a terminal opening brace
                 || ( ( $type eq '{' ) && ( $i_test == $imax ) )
@@ -22840,6 +22954,7 @@
         look_for_autoloader  => 1,
         look_for_selfloader  => 1,
         starting_line_number => 1,
+        extended_syntax      => 0,
     );
     my %args = ( %defaults, @_ );
 
@@ -22914,6 +23029,7 @@
         _nearly_matched_here_target_at      => undef,
         _line_text                          => "",
         _rlower_case_labels_at              => undef,
+        _extended_syntax                    => $args{extended_syntax},
     };
 
     prepare_for_a_new_file();
@@ -24047,7 +24163,7 @@
     sub scan_identifier {
         ( $i, $tok, $type, $id_scan_state, $identifier ) =
           scan_identifier_do( $i, $id_scan_state, $identifier, $rtokens,
-            $max_token_index, $expecting );
+            $max_token_index, $expecting, $paren_type[$paren_depth] );
     }
 
     sub scan_id {
@@ -24107,7 +24223,8 @@
     # keyword ( .... ) { BLOCK }
     # patch for SWITCH/CASE: added 'switch' 'case' 'given' 'when'
     my %is_blocktype_with_paren;
-    @_ = qw(if elsif unless while until for foreach switch case given when);
+    @_ =
+      qw(if elsif unless while until for foreach switch case given when catch);
     @is_blocktype_with_paren{@_} = (1) x scalar(@_);
 
     # ------------------------------------------------------------
@@ -24190,6 +24307,9 @@
                 $container_type = $want_paren;
                 $want_paren     = "";
             }
+            elsif ( $statement_type =~ /^sub/ ) {
+                $container_type = $statement_type;
+            }
             else {
                 $container_type = $last_nonblank_token;
 
@@ -24393,7 +24513,7 @@
             if ($is_pattern) {
                 $in_quote                = 1;
                 $type                    = 'Q';
-                $allowed_quote_modifiers = '[msixpodualgc]';
+                $allowed_quote_modifiers = '[msixpodualngc]';
             }
             else {    # not a pattern; check for a /= token
 
@@ -24448,9 +24568,21 @@
 
                 # check for syntax error here;
                 unless ( $is_blocktype_with_paren{$last_nonblank_token} ) {
-                    my $list = join( ' ', sort keys %is_blocktype_with_paren );
-                    warning(
-                        "syntax error at ') {', didn't see one of: $list\n");
+                    if ( $tokenizer_self->{'_extended_syntax'} ) {
+
+                        # we append a trailing () to mark this as an unknown
+                        # block type.  This allows perltidy to format some
+                        # common extensions of perl syntax.
+                        # This is used by sub code_block_type
+                        $last_nonblank_token .= '()';
+                    }
+                    else {
+                        my $list =
+                          join( ' ', sort keys %is_blocktype_with_paren );
+                        warning(
+"syntax error at ') {', didn't see one of: <<$list>>; If this code is okay try 
using the -xs flag\n"
+                        );
+                    }
                 }
             }
 
@@ -24608,7 +24740,7 @@
             if ($is_pattern) {
                 $in_quote                = 1;
                 $type                    = 'Q';
-                $allowed_quote_modifiers = '[msixpodualgc]';
+                $allowed_quote_modifiers = '[msixpodualngc]';
             }
             else {
                 ( $type_sequence, $indent_flag ) =
@@ -24972,21 +25104,22 @@
         '__DATA__' => '_in_data',
     );
 
-    # ref: camel 3 p 147,
+    # original ref: camel 3 p 147,
     # but perl may accept undocumented flags
     # perl 5.10 adds 'p' (preserve)
-    # Perl version 5.16, http://perldoc.perl.org/perlop.html,  has these:
-    # /PATTERN/msixpodualgc or m?PATTERN?msixpodualgc
-    # s/PATTERN/REPLACEMENT/msixpodualgcer
+    # Perl version 5.22 added 'n'
+    # From http://perldoc.perl.org/perlop.html we have
+    # /PATTERN/msixpodualngc or m?PATTERN?msixpodualngc
+    # s/PATTERN/REPLACEMENT/msixpodualngcer
     # y/SEARCHLIST/REPLACEMENTLIST/cdsr
     # tr/SEARCHLIST/REPLACEMENTLIST/cdsr
-    # qr/STRING/msixpodual
+    # qr/STRING/msixpodualn
     my %quote_modifiers = (
-        's'  => '[msixpodualgcer]',
+        's'  => '[msixpodualngcer]',
         'y'  => '[cdsr]',
         'tr' => '[cdsr]',
-        'm'  => '[msixpodualgc]',
-        'qr' => '[msixpodual]',
+        'm'  => '[msixpodualngc]',
+        'qr' => '[msixpodualn]',
         'q'  => "",
         'qq' => "",
         'qw' => "",
@@ -26533,7 +26666,7 @@
                         # otherwise, the token after a ',' starts a new term
 
                         # Patch FOR RT#99961; no continuation after a ';'
-                       # This is needed because perltidy currently marks
+                        # This is needed because perltidy currently marks
                         # a block preceded by a type character like % or @
                         # as a non block, to simplify formatting. But these
                         # are actually blocks and can have semicolons.
@@ -27034,6 +27167,12 @@
         }
     }
 
+    # handle unknown syntax ') {'
+    # we previously appended a '()' to mark this case
+    elsif ( $last_nonblank_token =~ /\(\)$/ ) {
+        return $last_nonblank_token;
+    }
+
     # anything else must be anonymous hash reference
     else {
         return "";
@@ -28146,7 +28285,7 @@
     # $last_nonblank_type
 
     my ( $i, $id_scan_state, $identifier, $rtokens, $max_token_index,
-        $expecting )
+        $expecting, $container_type )
       = @_;
     my $i_begin   = $i;
     my $type      = '';
@@ -28157,6 +28296,8 @@
     my $tok                 = $tok_begin;
     my $message             = "";
 
+    my $in_prototype_or_signature = $container_type =~ /^sub/;
+
     # these flags will be used to help figure out the type:
     my $saw_alpha = ( $tok =~ /^[A-Za-z_]/ );
     my $saw_type;
@@ -28364,6 +28505,13 @@
             }
             else {    # something else
 
+                if ( $in_prototype_or_signature && $tok =~ /^[\),=]/ ) {
+                    $id_scan_state = '';
+                    $i             = $i_save;
+                    $type          = 'i';       # probably punctuation variable
+                    last;
+                }
+
                 # check for various punctuation variables
                 if ( $identifier =~ /^[\$\*\@\%]$/ ) {
                     $identifier .= $tok;
@@ -28679,20 +28827,16 @@
         my $pos_beg = $$rtoken_map[$i_beg];
         pos($input_line) = $pos_beg;
 
-        # sub NAME PROTO ATTRS
+        # Look for the sub NAME
         if (
             $input_line =~ m/\G\s*
         ((?:\w*(?:'|::))*)  # package - something that ends in :: or '
         (\w+)               # NAME    - required
-        (\s*\([^){]*\))?    # PROTO   - something in parens
-        (\s*:)?             # ATTRS   - leading : of attribute list
         /gcx
           )
         {
             $match   = 1;
             $subname = $2;
-            $proto   = $3;
-            $attrs   = $4;
 
             $package = ( defined($1) && $1 ) ? $1 : $current_package;
             $package =~ s/\'/::/g;
@@ -28704,20 +28848,35 @@
             $type = 'i';
         }
 
-        # Look for prototype/attributes not preceded on this line by subname;
-        # This might be an anonymous sub with attributes,
+        # Now look for PROTO ATTRS
+        # Look for prototype/attributes which are usually on the same
+        # line as the sub name but which might be on a separate line.
+        # For example, we might have an anonymous sub with attributes,
         # or a prototype on a separate line from its sub name
-        elsif (
-            $input_line =~ m/\G(\s*\([^){]*\))?  # PROTO
+
+        # NOTE: We only want to parse PROTOTYPES here. If we see anything that
+        # does not look like a prototype, we assume it is a SIGNATURE and we
+        # will stop and let the the standard tokenizer handle it.  In
+        # particular, we stop if we see any nested parens, braces, or commas.
+        my $saw_opening_paren = $input_line =~ /\G\s*\(/;
+        if (
+            $input_line =~ m/\G(\s*\([^\)\(\}\{\,]*\))?  # PROTO
             (\s*:)?                              # ATTRS leading ':'
             /gcx
             && ( $1 || $2 )
           )
         {
-            $match = 1;
             $proto = $1;
             $attrs = $2;
 
+            # If we also found the sub name on this call then append PROTO.
+            # This is not necessary but for compatability with previous
+            # versions when the -csc flag is used:
+            if ( $match && $proto ) {
+                $tok .= $proto;
+            }
+            $match ||= 1;
+
             # Handle prototype on separate line from subname
             if ($subname_saved) {
                 $package = $package_saved;
@@ -28744,8 +28903,8 @@
                 $in_attribute_list = 1;
             }
 
-            # We must convert back from character position
-            # to pre_token index.
+            # Otherwise, if we found a match we must convert back from
+            # string position to the pre_token index for continued parsing.
             else {
 
                 # I don't think an error flag can occur here ..but ?
@@ -28773,6 +28932,8 @@
             }
             $package_saved = "";
             $subname_saved = "";
+
+            # See what's next...
             if ( $next_nonblank_token eq '{' ) {
                 if ($subname) {
 
@@ -28804,19 +28965,21 @@
                 $statement_type = $tok;
             }
 
-            # see if PROTO follows on another line:
+            # if we stopped before an open paren ...
             elsif ( $next_nonblank_token eq '(' ) {
-                if ( $attrs || $proto ) {
-                    warning(
-"unexpected '(' after definition or declaration of sub '$subname'\n"
-                    );
-                }
-                else {
-                    $id_scan_state  = 'sub';    # we must come back to get 
proto
-                    $statement_type = $tok;
-                    $package_saved  = $package;
-                    $subname_saved  = $subname;
+
+                # If we DID NOT see this paren above then it must be on the
+                # next line so we will set a flag to come back here and see if
+                # it is a PROTOTYPE
+
+                # Otherwise, we assume it is a SIGNATURE rather than a
+                # PROTOTYPE and let the normal tokenizer handle it as a list
+                if ( !$saw_opening_paren ) {
+                    $id_scan_state = 'sub';     # we must come back to get 
proto
+                    $package_saved = $package;
+                    $subname_saved = $subname;
                 }
+                $statement_type = $tok;
             }
             elsif ($next_nonblank_token) {      # EOF technically ok
                 warning(
@@ -29804,11 +29967,11 @@
 
     my @digraphs = qw(
       .. :: << >> ** && .. || // -> => += -= .= %= &= |= ^= *= <>
-      <= >= == =~ !~ != ++ -- /= x= ~~
+      <= >= == =~ !~ != ++ -- /= x= ~~ ~. |. &. ^.
     );
     @is_digraph{@digraphs} = (1) x scalar(@digraphs);
 
-    my @trigraphs = qw( ... **= <<= >>= &&= ||= //= <=> !~~ );
+    my @trigraphs = qw( ... **= <<= >>= &&= ||= //= <=> !~~ &.= |.= ^.=);
     @is_trigraph{@trigraphs} = (1) x scalar(@trigraphs);
 
     # make a hash of all valid token types for self-checking the tokenizer
@@ -29839,11 +30002,12 @@
     @is_indirect_object_taker{@_} = (1) x scalar(@_);
 
     # These tokens may precede a code block
-    # patched for SWITCH/CASE
+    # patched for SWITCH/CASE/CATCH.  Actually these could be removed
+    # now and we could let the extended-syntax coding handle them
     @_ =
       qw( BEGIN END CHECK INIT AUTOLOAD DESTROY UNITCHECK continue if elsif 
else
       unless do while until eval for foreach map grep sort
-      switch case given when);
+      switch case given when catch);
     @is_code_block_token{@_} = (1) x scalar(@_);
 
     # I'll build the list of keywords incrementally
@@ -30145,6 +30309,7 @@
       **= += -= .= /= *= %= x= &= |= ^= <<= >>= &&= ||= //=
       <= >= == != => \ > < % * / ? & | ** <=> ~~ !~~
       f F pp mm Y p m U J G j >> << ^ t
+      ~. ^. |. &. ^.= |.= &.=
       #;
     push( @value_requestor_type, ',' )
       ;    # (perl doesn't like a ',' in a qw block)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Perl-Tidy-20150815/lib/Perl/Tidy.pod 
new/Perl-Tidy-20160302/lib/Perl/Tidy.pod
--- old/Perl-Tidy-20150815/lib/Perl/Tidy.pod    2015-08-15 02:14:25.000000000 
+0200
+++ new/Perl-Tidy-20160302/lib/Perl/Tidy.pod    2016-03-01 14:31:55.000000000 
+0100
@@ -415,7 +415,7 @@
 
 =head1 VERSION
 
-This man page documents Perl::Tidy version 20150815.
+This man page documents Perl::Tidy version 20160302.
 
 =head1 LICENSE
 


Reply via email to