@@ -3183,6 +3183,7 @@ use constant {
3183
3183
LOCATION => 3,
3184
3184
UNCHANGED => 4,
3185
3185
ALIASES => 5,
3186
+ DIFF_ROOT => 6,
3186
3187
3187
3188
OLD => 0,
3188
3189
NEW => 1,
@@ -3266,6 +3267,25 @@ sub findName
3266
3267
my ($self , $file ) = @_ ;
3267
3268
my $f = $lcovutil::case_insensitive ? lc ($file ) : $file ;
3268
3269
$f = $self -> [ALIASES]-> {$f } if exists ($self -> [ALIASES]-> {$f });
3270
+
3271
+ if (File::Spec-> file_name_is_absolute($f ) &&
3272
+ !exists ($self -> [LINEMAP]-> {$f })) {
3273
+ my $p =
3274
+ $lcovutil::case_insensitive ?
3275
+ lc ($self -> [DIFF_ROOT]) :
3276
+ $self -> [DIFF_ROOT];
3277
+ $p .= $lcovutil::dirseparator ;
3278
+ my $l = length ($p );
3279
+ my $s = substr ($f , $l );
3280
+ if (length ($f ) > $l &&
3281
+ $p eq substr ($f , 0, $l )) {
3282
+ if (exists ($self -> [LINEMAP]-> {$s })) {
3283
+ $f = $s ;
3284
+ } elsif (exists ($self -> [ALIASES]-> {$s })) {
3285
+ $f = $self -> [ALIASES]-> {$s };
3286
+ }
3287
+ }
3288
+ }
3269
3289
return $f ;
3270
3290
}
3271
3291
@@ -3574,8 +3594,7 @@ sub _read_udiff
3574
3594
my $time =
3575
3595
' [1-9]{1}[0-9]{3}\-[0-9]{2}\-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]*)?( .[0-9]+)?' ;
3576
3596
# Parse diff file line by line
3577
- my $verbose = 0;
3578
- my $diffRoot = $main::cwd ; # default root
3597
+ my $verbose = 0;
3579
3598
while (<$diffHdl >) {
3580
3599
chomp ($_ );
3581
3600
s /\r // g ;
@@ -3589,7 +3608,7 @@ sub _read_udiff
3589
3608
}
3590
3609
foreach ($line ) {
3591
3610
/ ^Git Root: (.+)$ / && do {
3592
- $diffRoot = $1 ;
3611
+ $self -> [DIFF_ROOT] = $1 ;
3593
3612
last ;
3594
3613
};
3595
3614
@@ -3604,7 +3623,7 @@ sub _read_udiff
3604
3623
push (@{$self -> [LINEMAP]-> {$filename }}, $chunk );
3605
3624
undef $filename ;
3606
3625
}
3607
- my $file = File::Spec -> rel2abs( $1 , $diffRoot ) ;
3626
+ my $file = $1 ;
3608
3627
$file = lcovutil::strip_directories($file , $main::strip );
3609
3628
my $key = ReadCurrentSource::resolve_path($file , 1);
3610
3629
$key = lc ($key ) if $lcovutil::case_insensitive ;
@@ -3644,7 +3663,7 @@ sub _read_udiff
3644
3663
push (@{$self -> [LINEMAP]-> {$filename }}, $chunk );
3645
3664
undef $filename ;
3646
3665
}
3647
- $file_old = File::Spec -> rel2abs( $1 , $diffRoot ) ;
3666
+ $file_old = $1 ;
3648
3667
$file_old =
3649
3668
lcovutil::strip_directories($file_old , $main::strip );
3650
3669
$file_old = ReadCurrentSource::resolve_path($file_old , 1);
@@ -3656,7 +3675,7 @@ sub _read_udiff
3656
3675
# +++ <filename>
3657
3676
/ ^\+\+\+ (.+)$ / && do {
3658
3677
# Add last file to resulting hash
3659
- $file_new = File::Spec -> rel2abs( $1 , $diffRoot ) ;
3678
+ $file_new = $1 ;
3660
3679
$file_new =
3661
3680
lcovutil::strip_directories($file_new , $main::strip );
3662
3681
my $key = ReadCurrentSource::resolve_path($file_new , 1);
@@ -3804,6 +3823,9 @@ sub _read_udiff
3804
3823
_printChunk($chunk ) if ($verbose );
3805
3824
}
3806
3825
3826
+ # default root
3827
+ $self -> [DIFF_ROOT] = $main::cwd unless defined ($self -> [DIFF_ROOT]);
3828
+
3807
3829
if ($self -> empty()) {
3808
3830
# this is probably OK - there are no differences between 'baseline' and current.
3809
3831
lcovutil::ignorable_error($lcovutil::ERROR_EMPTY ,
0 commit comments