Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch: add paths to error messages #941

Merged
merged 1 commit into from
Feb 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions bin/patch
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use constant EX_SUCCESS => 0;
use constant EX_REJECTS => 1;
use constant EX_FAILURE => 2;

my $VERSION = '0.31';
my $VERSION = '0.32';

$|++;

Expand Down Expand Up @@ -434,11 +434,12 @@ sub bless {
}

# Open original file.
local *IN;
open IN, '<', $in or $self->skip("Couldn't open INFILE: $!\n");
binmode IN;
$self->{i_fh} = *IN; # input filehandle
$self->{i_file} = $in; # input filename
my $in_fh;
open $in_fh, '<', $in
or $self->skip("Cannot open input file '$in': $!\n");
binmode $in_fh;
$self->{'i_fh'} = $in_fh;
$self->{'i_file'} = $in;

# Open output file.
if ($self->{check}) {
Expand All @@ -448,13 +449,14 @@ sub bless {
$self->{'o_file'} = '-';
$self->{'d_fh'} = length $self->{'ifdef'} ? *STDOUT : File::Temp->new;
} else {
local *OUT;
open OUT, '+>', $out or $self->skip("Couldn't open OUTFILE: $!\n");
binmode OUT;
$|++, select $_ for select OUT;
$self->{o_fh} = *OUT;
$self->{o_file} = $out;
$self->{d_fh} = length $self->{ifdef} ? *OUT : File::Temp->new();
my $out_fh;
open $out_fh, '+>', $out
or $self->skip("Cannot open output file '$out': $!\n");
binmode $out_fh;
$|++, select $_ for select $out_fh;
$self->{'o_fh'} = $out_fh;
$self->{'o_file'} = $out;
$self->{'d_fh'} = length $self->{'ifdef'} ? $out_fh : File::Temp->new();
}

$self->{'reject-file'} = "$out.rej" unless defined $self->{'reject-file'};
Expand Down
Loading