GNU bug report logs - #16329
`head --lines=-0' prints nothing if no newline at the EOF

Previous Next

Package: coreutils;

Reported by: Алексей Шилин <rootlexx <at> mail.ru>

Date: Fri, 3 Jan 2014 16:31:01 UTC

Severity: normal

Merged with 16559, 16560, 16561

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Pádraig Brady <P <at> draigBrady.com>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#16559: closed (Bug report for 'head' (and 'wc' et. al.))
Date: Wed, 29 Jan 2014 11:57:03 +0000
[Message part 1 (text/plain, inline)]
Your message dated Wed, 29 Jan 2014 11:55:53 +0000
with message-id <52E8EC49.1090103 <at> draigBrady.com>
and subject line Re: bug#16329: Acknowledgement (`head --lines=-0' prints nothing if no newline at the EOF)
has caused the debbugs.gnu.org bug report #16329,
regarding Bug report for 'head' (and 'wc' et. al.)
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
16329: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16329
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: LGUC <lguribec <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: Bug report for 'head' (and 'wc' et. al.)
Date: Sun, 26 Jan 2014 10:28:50 -0430
[Message part 3 (text/html, inline)]
[Message part 4 (message/rfc822, inline)]
From: Pádraig Brady <P <at> draigBrady.com>
To: Алексей Шилин <rootlexx <at> mail.ru>
Cc: 16329-done <at> debbugs.gnu.org
Subject: Re: bug#16329: Acknowledgement (`head --lines=-0' prints nothing
 if no newline at the EOF)
Date: Wed, 29 Jan 2014 11:55:53 +0000
[Message part 5 (text/plain, inline)]
On 01/03/2014 08:40 PM, Алексей Шилин wrote:
> Looks like I was overly cautious about decrementing an unsigned...
> 
> size_t n = bytes_read;
> while (n)
>   {
>     if (all_lines)
>       n -= n ? 1 : 0;        // ...here.
>     else
> 
> As it is under `while (n)' statement, n is always true here, and thus the ternary operator, though makes no
> harm, is needless, and the whole line can be replaced with just `n--;'. Sorry for that.
> 
> The fixed version of the original patch is attached.
> 

I've updated the patch to also handle the pipe case,
and I added a test. Will push soon.

thanks,
Pádraig.
[head--lines-0.patch (text/x-patch, attachment)]

This bug report was last modified 11 years and 118 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.