Re: [PATCH] git-svn: avoid warning on undef readline()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 06 2018, Eric Wong wrote:

> Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> wrote:
>> On Fri, Apr 06 2018, Eric Wong wrote:
>> > Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> wrote:
>> >
>> >> --- a/perl/Git.pm
>> >> +++ b/perl/Git.pm
>> >> @@ -554,7 +554,7 @@ sub get_record {
>> >>  	my ($fh, $rs) = @_;
>> >>  	local $/ = $rs;
>> >>  	my $rec = <$fh>;
>> >> -	chomp $rec if defined $rs;
>> >> +	chomp $rec if defined $rs and defined $rec;
>> >
>> > I'm struggling to understand the reason for the "defined $rs"
>> > check.  I think it was a braino on my part and meant to use:
>> >
>> > 	chomp $rec if defined $rec;
>>
>> Whether this makes any sense is another question, but you seem to have
>> explicitly meant this at the time. The full function definition with
>> documentation:
>>
>>     =item get_record ( FILEHANDLE, INPUT_RECORD_SEPARATOR )
>>
>>     Read one record from FILEHANDLE delimited by INPUT_RECORD_SEPARATOR,
>>     removing any trailing INPUT_RECORD_SEPARATOR.
>
> I've always known chomp to respect the value of $/; so chomp($rec)
> whould only cut out whatever $rs is, and be a no-op if $rs is undef.

Yup, you're right. I missed that.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux