Subject: bug#16561: Bug report for 'head' (and 'wc' et. al.)

From: LGUC <[email-masked]>
Date: Sun, 26 Jan 2014 10:37:54 -0430

THE INCOMPLETE ATTACMENT! (working on sunday makes not my lucky day. Sorry for the inconveniences!.
Please disregard the previous 2 mails)

Caracas, Sunday 26th, 2014

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 line 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)