|
From: | GNU bug Tracking System |
Subject: | [debbugs-tracker] bug#16559: closed (Bug report for 'head' (and 'wc' et. al.)) |
Date: | Wed, 29 Jan 2014 11:57:03 +0000 |
Your message dated Wed, 29 Jan 2014 11:55:53 +0000 with message-id <address@hidden> 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 address@hidden) -- 16329: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16329 GNU Bug Tracking System Contact address@hidden with problems
--- Begin Message ---Subject: Bug report for 'head' (and 'wc' et. al.) Caracas, Sunday 26th, 2014 Date: Sun, 26 Jan 2014 10:28:50 -0430
Ref: Bug report for 'head' (and 'wc' et. al.)
Dear friends:
Please find attached the text file 'head-tst.txt'
As you easily can see, the following command fails and do not print
anything, even if the file has: 6 lines, 49 words and 250 chars:
'head -n -0 head-tst.txt'
The last line on the file does NOT end with a '\n', and this seems
to be the base of the problem. If you add the last '\n', 'head' works
pretty fine.
So this seems to be a problem with the definition of a 'text line':
I guess that a line that has around 68 normal chars and 13 spaces, is
a good candidate to be considered as a line.
I found the same problem in several other core utils, being the
most remarcable 'wc'. If you executes:
'wc head-tst.txt'
you will get:
5 49 250 head-tst.txt
what is wrong, as the file has six (6) lines instead of five (5).
The last one lines is missing due to the fact that it does not
include a '\n' at the end.
In 1998 I fix 'wc', and I have attached 'wc-fix.c' including only
the most remarkable aspects, in case it could be of any help.
Best regards,
Luis G. Uribe C.
Attachments inside 'head-tst.zip':
- 'head-tst.txt': text file that makes 'head' core utility to fail
- 'wc-fix.c': fix to same problem, applyied to 'wc' in 1998
Software ID:
GNU coreutils 8.15 January 2012 HEAD(1)
(Cygwin)
--- End Message ---
--- Begin Message ---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 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2 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
Description: Text Data
--- End Message ---
[Prev in Thread] | Current Thread | [Next in Thread] |