Christian Couder <christian.couder@xxxxxxxxx> writes: > As checking for a lf character at the end of a buffer > will be useful in another function, let's refactor this > functionality into a small remove_final_lf_or_die() > helper function. > > Signed-off-by: Christian Couder <chriscool@xxxxxxxxxxxxx> > --- > t/t0021/rot13-filter.pl | 14 +++++++++++--- > 1 file changed, 11 insertions(+), 3 deletions(-) > > diff --git a/t/t0021/rot13-filter.pl b/t/t0021/rot13-filter.pl > index 2f74ab2e45..d47b7f5666 100644 > --- a/t/t0021/rot13-filter.pl > +++ b/t/t0021/rot13-filter.pl > @@ -93,12 +93,20 @@ sub packet_bin_read { > } > } > > -sub packet_txt_read { > - my ( $res, $buf ) = packet_bin_read(); > - unless ( $res == -1 or $buf eq '' or $buf =~ s/\n$// ) { > +sub remove_final_lf_or_die { > + my $buf = shift; > + unless ( $buf =~ s/\n$// ) { > die "A non-binary line MUST be terminated by an LF.\n" > . "Received: '$buf'"; > } > + return $buf; > +} > + > +sub packet_txt_read { > + my ( $res, $buf ) = packet_bin_read(); > + unless ( $res == -1 or $buf eq '' ) { > + $buf = remove_final_lf_or_die($buf); > + } After patch 2/8 I found the "unless" in packet_txt_read impossible to read, but this makes it a bit more understandable.