r50429 - in /branches/upstream/libtext-findindent-perl/current: Changes MANIFEST META.yml lib/Text/FindIndent.pm t/data/spaces4_2.txt t/data/spaces4_3.txt t/data/spaces4_4.txt t/data/tabs8_1_skippod.txt
jawnsy-guest at users.alioth.debian.org
jawnsy-guest at users.alioth.debian.org
Thu Jan 7 04:43:16 UTC 2010
Author: jawnsy-guest
Date: Thu Jan 7 04:43:10 2010
New Revision: 50429
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=50429
Log:
[svn-upgrade] Integrating new upstream version, libtext-findindent-perl (0.08)
Added:
branches/upstream/libtext-findindent-perl/current/t/data/spaces4_2.txt
branches/upstream/libtext-findindent-perl/current/t/data/spaces4_3.txt
branches/upstream/libtext-findindent-perl/current/t/data/spaces4_4.txt
branches/upstream/libtext-findindent-perl/current/t/data/tabs8_1_skippod.txt
Modified:
branches/upstream/libtext-findindent-perl/current/Changes
branches/upstream/libtext-findindent-perl/current/MANIFEST
branches/upstream/libtext-findindent-perl/current/META.yml
branches/upstream/libtext-findindent-perl/current/lib/Text/FindIndent.pm
Modified: branches/upstream/libtext-findindent-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-findindent-perl/current/Changes?rev=50429&op=diff
==============================================================================
--- branches/upstream/libtext-findindent-perl/current/Changes (original)
+++ branches/upstream/libtext-findindent-perl/current/Changes Thu Jan 7 04:43:10 2010
@@ -1,4 +1,12 @@
Changes for Perl extension Text-FindIndent
+
+0.08
+ - Handle case where hash keys and values are indented by braces pos + 1
+ (CHORNY)
+ - Check if indent level is same on next line and slightly increase probability of
+ current indent type. Should be faster too. (CHORNY)
+ - Add option 'first_level_indent_only' to check only indent where previous line
+ is empty. (CHORNY)
0.07
- ~40% faster since 0.05
Modified: branches/upstream/libtext-findindent-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-findindent-perl/current/MANIFEST?rev=50429&op=diff
==============================================================================
--- branches/upstream/libtext-findindent-perl/current/MANIFEST (original)
+++ branches/upstream/libtext-findindent-perl/current/MANIFEST Thu Jan 7 04:43:10 2010
@@ -26,9 +26,13 @@
t/data/spaces3_2.txt
t/data/spaces3_3.txt
t/data/spaces4_1.txt
+t/data/spaces4_2.txt
+t/data/spaces4_3.txt
+t/data/spaces4_4.txt
t/data/spaces5_1.txt
t/data/spaces6_1.txt
t/data/tabs8_1.txt
+t/data/tabs8_1_skippod.txt
t/data/tabs8_2.txt
t/data/tabs8_3.txt
t/data/unknown_1.txt
Modified: branches/upstream/libtext-findindent-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-findindent-perl/current/META.yml?rev=50429&op=diff
==============================================================================
--- branches/upstream/libtext-findindent-perl/current/META.yml (original)
+++ branches/upstream/libtext-findindent-perl/current/META.yml Thu Jan 7 04:43:10 2010
@@ -23,4 +23,4 @@
perl: 5.00503
resources:
license: http://dev.perl.org/licenses/
-version: 0.07
+version: 0.08
Modified: branches/upstream/libtext-findindent-perl/current/lib/Text/FindIndent.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-findindent-perl/current/lib/Text/FindIndent.pm?rev=50429&op=diff
==============================================================================
--- branches/upstream/libtext-findindent-perl/current/lib/Text/FindIndent.pm (original)
+++ branches/upstream/libtext-findindent-perl/current/lib/Text/FindIndent.pm Thu Jan 7 04:43:10 2010
@@ -73,7 +73,7 @@
use vars qw{$VERSION};
BEGIN {
- $VERSION = '0.07';
+ $VERSION = '0.08';
}
use constant MAX_LINES => 500;
@@ -86,6 +86,7 @@
my $textref = ref($text) ? $text : \$text; # accept references, too
my $skip_pod = $opts{skip_pod};
+ my $first_level_indent_only = $opts{first_level_indent_only}?1:0;
my %modeline_settings;
@@ -112,6 +113,8 @@
return( "s" . $modeline_settings{tabstop} );
}
+ my $next_line_braces_pos_plus_1;
+ my $prev_indent_type = undef;
while ($$textref =~ /\G([ \t]*)([^\r\n]*)[\r\n]+/cgs) {
my $ws = $1;
my $rest = $2;
@@ -178,10 +181,35 @@
# skip single-line comments
next if $rest =~ /^(?:#|\/\/|\/\*)/; # TODO: parse /* ... */!
+ if ($next_line_braces_pos_plus_1) {
+ if ($next_line_braces_pos_plus_1==_length_with_tabs_converted($ws)) {
+ next;
+ }
+ $next_line_braces_pos_plus_1=0;
+ } else {
+ if ($rest=~/=> {$/) { #handle case where hash keys and values are indented by braces pos + 1
+ $next_line_braces_pos_plus_1=_length_with_tabs_converted($ws)+length($rest);
+ }
+ }
+
+ if ($first_level_indent_only and $prev_indent ne '') {
+ next;
+ }
+
+ if ($prev_indent eq $ws) {
+ if ($prev_indent_type) {
+ $indentdiffs{$prev_indent_type}+=0.01;
+ #coefficient is not based on data, so change if you think it should be different
+ }
+ next;
+ }
+
# prefix-matching higher indentation level
if ($ws =~ /^\Q$prev_indent\E(.+)$/) {
my $diff = $1;
- _grok_indent_diff($diff, \%indentdiffs);
+ my $indent_type=_analyse_indent_diff($diff);
+ $indentdiffs{$indent_type}++;
+ $prev_indent_type=$indent_type;
$prev_indent = $ws;
next;
}
@@ -189,7 +217,10 @@
# prefix-matching lower indentation level
if ($prev_indent =~ /^\Q$ws\E(.+)$/) {
my $diff = $1;
- _grok_indent_diff($diff, \%indentdiffs);
+ #_grok_indent_diff($diff, \%indentdiffs);
+ my $indent_type=_analyse_indent_diff($diff);
+ $indentdiffs{$indent_type}++;
+ $prev_indent_type=$indent_type;
$prev_indent = $ws;
next;
}
@@ -256,6 +287,15 @@
return $maxkey;
}
+sub _length_with_tabs_converted {
+ my $str=shift;
+ my $tablen=shift || 8;
+ $str =~ s/( +)$//;
+ my $trailing_spaces = $1;
+ $str =~ s/ +//g; # assume the spaces are all contained in tabs!
+ return length($str)*$tablen+length($trailing_spaces);
+}
+
sub _grok_indent_diff {
my $diff = shift;
my $indentdiffs = shift;
@@ -274,9 +314,26 @@
}
}
+sub _analyse_indent_diff {
+ my $diff = shift;
+
+ if ($diff =~ /^ +$/) {
+ return "s" . length($diff);
+ }
+ elsif ($diff =~ /^\t+$/) {
+ return "t8"; # we can't infer what a tab means. Or rather, we need smarter code to do it
+ }
+ else { # mixed!
+ $diff =~ s/( +)$//;
+ my $trailing_spaces = $1;
+ $diff =~ s/ +//g; # assume the spaces are all contained in tabs!
+ return "m" . (length($diff)*8+length($trailing_spaces));
+ }
+}
+
{
# the vim modeline regexes
- my $VimTag = qr/(?:ex|vi(?:m(?:[<=>]\d+)?)?):/;
+ my $VimTag = qr/(?:ex|vim?(?:[<=>]\d+)?):/;
my $OptionArg = qr/[^\s\\]*(?:\\[\s\\][^\s\\]*)*/;
my $VimOption = qr/
\w+(?:=)?$OptionArg
@@ -346,18 +403,14 @@
# /* vim: set ai tw=75: */ ~
#
- my $changed = 0;
my @options;
- if ($line =~ $VimModeLineStart) {
- if ($line =~ $VimModelineTypeOne) {
- push @options, split /(?!<\\)[:\s]+/, $1;
- }
- elsif ($line =~ $VimModelineTypeTwo) {
- push @options, split /(?!<\\)\s+/, $1;
- }
- else {
- return;
- }
+ return if $line !~ $VimModeLineStart;
+
+ if ($line =~ $VimModelineTypeOne) {
+ push @options, split /(?!<\\)[:\s]+/, $1;
+ }
+ elsif ($line =~ $VimModelineTypeTwo) {
+ push @options, split /(?!<\\)\s+/, $1;
}
else {
return;
@@ -365,6 +418,7 @@
return if not @options;
+ my $changed = 0;
foreach (@options) {
/s(?:ts|ofttabstop)=(\d+)/i and $settings->{softtabstop} = $1, $changed = 1, next;
/t(?:s|abstop)=(\d+)/i and $settings->{tabstop} = $1, $changed = 1, next;
Added: branches/upstream/libtext-findindent-perl/current/t/data/spaces4_2.txt
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-findindent-perl/current/t/data/spaces4_2.txt?rev=50429&op=file
==============================================================================
--- branches/upstream/libtext-findindent-perl/current/t/data/spaces4_2.txt (added)
+++ branches/upstream/libtext-findindent-perl/current/t/data/spaces4_2.txt Thu Jan 7 04:43:10 2010
@@ -1,0 +1,9 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ PREREQ_PM => {
+ 'Test::More' => 0,
+ 'Yahoo::Search::XML' => '20060729.004',
+ 'LWP::UserAgent' => 0,
+ },
+);
Added: branches/upstream/libtext-findindent-perl/current/t/data/spaces4_3.txt
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-findindent-perl/current/t/data/spaces4_3.txt?rev=50429&op=file
==============================================================================
--- branches/upstream/libtext-findindent-perl/current/t/data/spaces4_3.txt (added)
+++ branches/upstream/libtext-findindent-perl/current/t/data/spaces4_3.txt Thu Jan 7 04:43:10 2010
@@ -1,0 +1,14 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ PL_FILES => {},
+ LICENSE => 'perl',
+ PREREQ_PM => {
+ 'Test::More' => 0,
+ 'Yahoo::Search::XML' => '20060729.004',
+ 'LWP::UserAgent' => 0,
+ 'URI' => 1.36,
+ 'Encode' => 0, #this line has tabs
+ },
+ dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
+);
Added: branches/upstream/libtext-findindent-perl/current/t/data/spaces4_4.txt
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-findindent-perl/current/t/data/spaces4_4.txt?rev=50429&op=file
==============================================================================
--- branches/upstream/libtext-findindent-perl/current/t/data/spaces4_4.txt (added)
+++ branches/upstream/libtext-findindent-perl/current/t/data/spaces4_4.txt Thu Jan 7 04:43:10 2010
@@ -1,0 +1,9 @@
+use ExtUtils::MakeMaker;
+WriteMakefile(
+ NAME => '',
+ VERSION_FROM => '', # finds $VERSION
+ PREREQ_PM => {}, # e.g., Module::Name => 1.1
+ ($] >= 5.005 ? ## Add these new keywords supported since 5.005
+ (ABSTRACT_FROM => '', # retrieve abstract from module
+ AUTHOR => '') : ()),
+);
Added: branches/upstream/libtext-findindent-perl/current/t/data/tabs8_1_skippod.txt
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libtext-findindent-perl/current/t/data/tabs8_1_skippod.txt?rev=50429&op=file
==============================================================================
--- branches/upstream/libtext-findindent-perl/current/t/data/tabs8_1_skippod.txt (added)
+++ branches/upstream/libtext-findindent-perl/current/t/data/tabs8_1_skippod.txt Thu Jan 7 04:43:10 2010
@@ -1,0 +1,62 @@
+
+=pod
+
+Blah blah
+
+ my $example = 'code';
+ foreach (@foo) {
+ foreach (@foo) {
+ my $example = 'code';
+ my $example = 'code';
+ my $example = 'code';
+ }
+ my $example = 'code';
+ my $example = 'code';
+ my $example = 'code';
+ foreach (@foo) {
+ my $example = 'code';
+ my $example = 'code';
+ my $example = 'code';
+ }
+ }
+
+Blah
+
+=cut
+
+
+use vars qw{$VERSION};
+BEGIN {
+ $VERSION = '0.01';
+}
+
+sub parse {
+ my $class = shift;
+ my $text = shift;
+ foreach my $foo (blah) {
+ foreach my $foo (blah) {
+ foreach my $foo (blah) {
+ foo;
+ }
+ }
+ }
+}
+
+
+=head1 Blurb
+
+blah
+
+ sub parse {
+ my $class = shift;
+ my $text = shift;
+ foreach my $foo (blah) {
+ foreach my $foo (blah) {
+ foreach my $foo (blah) {
+ foo;
+ }
+ }
+ }
+ }
+
+=cut
More information about the Pkg-perl-cvs-commits
mailing list