Subject: | applypatch silently fails to apply a "bare" patch |
Perl 5.16.3
Debian 7
applypatch 2.05
When passed a bare patch (i.e. one created with diff, not makepatch), applypatch silently fails to pass the patch to the patch program.
The problem occurs in copy_input.
The input patch file will not match any of the conditionals, so $pos is left at its initialized value of 0.
However, $pos is eventually passed to $tmpfile->setpos, which expects values returned by $tmpfile->getpos(). Passing it 0 isn't defined. In this case (on my platform) the file pointer is left at the end of the file rather than being set to the beginning of the file.
The solution is to change
105 my $pos = 0; # start of patch data
to
105 my $pos = $tmpfile->getpos; # start of patch data