@@ -24,7 +24,7 @@ use constant EX_SUCCESS => 0;
2424use constant EX_REJECTS => 1;
2525use constant EX_FAILURE => 2;
2626
27- my $VERSION = ' 0.33 ' ;
27+ my $VERSION = ' 0.34 ' ;
2828
2929$| ++;
3030
@@ -301,6 +301,7 @@ BEGIN {
301301
302302# Simple throw/catch error handling.
303303sub throw {
304+ my $self = shift ;
304305 $@ = join ' ' , @_ ;
305306 $@ .= sprintf " at %s line %d \n " , (caller )[1..2] unless $@ =~ / \n\z / ;
306307 goto CATCH;
@@ -382,7 +383,7 @@ sub bless {
382383 $self -> note(" Hmm... Looks like a$n $type diff to me...\n " );
383384
384385 # Get original file to patch...
385- my $orig = $self -> {origfile }; # ...from -o
386+ my $orig = $self -> {origfile };
386387
387388 unless (defined $orig ) {
388389 $orig = $self -> rummage($garbage ); # ...from leading garbage
@@ -681,7 +682,7 @@ sub suffix_backup {
681682sub apply {
682683 my ($self , $i_start , $o_start , @hunk ) = @_ ;
683684
684- $self -> {skip } and throw(' SKIP...ignore this patch' );
685+ $self -> {skip } and $self -> throw(' SKIP...ignore this patch' );
685686
686687 if ($self -> {reverse }) {
687688 my $not = { qw/ + - - + / };
@@ -729,15 +730,15 @@ sub apply {
729730 $self -> {reverse } = 0;
730731 $position = 0;
731732 prompt (' Apply anyway? [n] ' ) =~ / ^[yY]/
732- or throw(' SKIP...ignore this patch' );
733+ or $self -> throw(' SKIP...ignore this patch' );
733734 }
734735 }
735736 } else {
736- throw(' SKIP...ignore this patch' ) if $self -> {forward };
737+ $self -> throw(' SKIP...ignore this patch' ) if $self -> {forward };
737738 }
738739 }
739740 }
740- $position or throw(" Couldn't find anywhere to put hunk.\n " );
741+ $position or $self -> throw(" Couldn't find anywhere to put hunk.\n " );
741742 } else {
742743 # No context. Use given position.
743744 $position = [$i_start - $self -> {i_lines } - 1]
@@ -749,7 +750,7 @@ sub apply {
749750 my $ifdef = $self -> {ifdef };
750751
751752 # Make sure we're where we left off.
752- seek $in , $self -> {i_pos }, 0 or throw(" Couldn't seek INFILE: $! " );
753+ seek $in , $self -> {i_pos }, 0 or $self -> throw(" Couldn't seek INFILE: $! " );
753754
754755 my $line = $self -> {o_lines } + $position -> [0] + 1;
755756 my $off = $line - $o_start ;
@@ -815,7 +816,7 @@ sub index {
815816 my ($self , $match , $pos , $lines ) = @_ ;
816817 my $in = $self -> {i_fh };
817818
818- seek ($in , $pos , 0) or throw(" Couldn't seek INFILE [ $in , 0, $pos ] : $! " );
819+ seek ($in , $pos , 0) or $self -> throw(" Couldn't seek INFILE: $! " );
819820 <$in > while $lines --;
820821
821822 if ($self -> {' ignore-whitespace' }) {
@@ -835,7 +836,7 @@ sub index {
835836 $line eq $match -> [$_ ] or $fail ++, last ;
836837 }
837838 if ($fail ) {
838- seek ($in , $tell , 0) or throw(" Couldn't seek INFILE: $! " );
839+ seek ($in , $tell , 0) or $self -> throw(" Couldn't seek INFILE: $! " );
839840 <$in >;
840841 } else {
841842 return ($tell , $line );
@@ -916,7 +917,7 @@ use base 'Patch';
916917sub apply {
917918 my ($self , @cmd ) = @_ ;
918919
919- $self -> {skip } and throw(' SKIP...ignore this patch' );
920+ $self -> {skip } and $self -> throw(' SKIP...ignore this patch' );
920921
921922 my $out = $self -> {o_fh };
922923
@@ -937,16 +938,16 @@ sub apply {
937938 };
938939
939940 # Did pipe to ed work?
940- seek ($out , 0, 0) or throw(" Couldn't seek OUT: $! " );
941+ seek ($out , 0, 0) or $self -> throw(" Couldn't seek OUT: $! " );
941942 my $testline = <$out >;
942943 if (!$@ && $testline ne $magic ) {
943944 $self -> note(" Hunk #$self ->{hunk} succeeded at 1.\n " );
944945 return 1;
945946 }
946947
947948 # Erase any trace of magic line.
948- truncate ($out , 0) or throw(" Couldn't truncate OUT: $! " );
949- seek ($out , 0, 0) or throw(" Couldn't seek OUT: $! " );
949+ truncate ($out , 0) or $self -> throw(" Couldn't truncate OUT: $! " );
950+ seek ($out , 0, 0) or $self -> throw(" Couldn't seek OUT: $! " );
950951
951952 # Try to apply ed script by hand.
952953 $self -> note(" Pipe to ed failed. Switching to Plan J...\n " );
@@ -963,7 +964,7 @@ sub apply {
963964 my @hunk = @{$cmd [$i ]};
964965
965966 shift (@hunk ) =~ m ! ^(\d +)(?:,(\d +))?([acds])!
966- or throw(' Unable to parse ed script' );
967+ or $self -> throw(' Unable to parse ed script' );
967968
968969 my ($start , $end , $cmd ) = ($1 , $2 || $1 , $3 );
969970
0 commit comments