Show
Ignore:
Timestamp:
10/23/08 11:15:03 (5 years ago)
Author:
yappo
Message:

r438@haruna (orig r388): ko | 2007-06-10 15:30:59 +0900

r436@haruna: ko | 2007-06-10 15:29:31 +0900
fixed to invalid handling of zeros bug. rt.cpan #26493

Location:
lang/perl/String-Diff/trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/String-Diff/trunk/lib/String/Diff.pm

    r21924 r21926  
    5353    my @old_diff = (); 
    5454    my @new_diff = (); 
    55     my $old_str = ''; 
    56     my $new_str = ''; 
     55    my $old_str; 
     56    my $new_str; 
    5757 
    5858    my @diff = sdiff( map{[ split //, $_ ]} $old, $new); 
     
    6060    for my $line (@diff) { 
    6161        if ($last_mode ne $line->[0]) { 
    62             push @old_diff, [$last_mode, $old_str] if $old_str; 
    63             push @new_diff, [$last_mode, $new_str] if $new_str; 
     62            push @old_diff, [$last_mode, $old_str] if defined $old_str; 
     63            push @new_diff, [$last_mode, $new_str] if defined $new_str; 
    6464 
    6565            # skip concut 
    66             push @old_diff, ['s', ''] unless $old_str; 
    67             push @new_diff, ['s', ''] unless $new_str; 
    68  
    69             $old_str = $new_str = ''; 
     66            push @old_diff, ['s', ''] unless defined $old_str; 
     67            push @new_diff, ['s', ''] unless defined $new_str; 
     68 
     69            $old_str = $new_str = undef; 
    7070        } 
    7171  
     
    7474        $last_mode = $line->[0]; 
    7575    } 
    76     push @old_diff, [$last_mode, $old_str] if $old_str; 
    77     push @new_diff, [$last_mode, $new_str] if $new_str; 
     76    push @old_diff, [$last_mode, $old_str] if defined $old_str; 
     77    push @new_diff, [$last_mode, $new_str] if defined $new_str; 
    7878 
    7979    @old_diff = _fully_filter('-', @old_diff); 
     
    9494            next; 
    9595        } 
    96         push @filter, $last_line if $last_line->[1]; 
     96        push @filter, $last_line if length $last_line->[1]; 
    9797        $last_line = $line; 
    9898    } 
    99     push @filter, $last_line if $last_line->[1]; 
     99    push @filter, $last_line if length $last_line->[1]; 
    100100     
    101101    @filter; 
  • lang/perl/String-Diff/trunk/t/02_diff_fully.t

    r21918 r21926  
    277277options: 
    278278  linebreak: 1 
     279 
     280=== 
     281--- data1 
     282- 
     283  - ['u', '1'] 
     284  - ['-', '0'] 
     285- 
     286  - ['u', '1'] 
     287  - ['+', '1'] 
     288--- data2 
     289old: 10 
     290new: 11 
     291 
  • lang/perl/String-Diff/trunk/t/03_diff.t

    r21918 r21926  
    166166  append_open: <ins> 
    167167  append_close: </ins> 
     168 
     169=== 
     170--- data1 
     171- 1[0] 
     172- 1{1} 
     173--- data2 
     174old: 10 
     175new: 11 
     176 
  • lang/perl/String-Diff/trunk/t/04_diff_merge.t

    r21918 r21926  
    150150  append_open: <ins> 
    151151  append_close: </ins> 
     152 
     153=== 
     154--- data1 
     1551[0]{1} 
     156--- data2 
     157old: 10 
     158new: 11 
  • lang/perl/String-Diff/trunk/t/05_diff_regexp.t

    r21918 r21926  
    125125options: 
    126126  linebreak: 1 
     127 
     128=== 
     129--- data1 
     1301(?:0|1) 
     131--- data2 
     132old: 10 
     133new: 11