hi,
I am sending you a patch to solve a 'problem' at the wc program.
When used with -l option (to count the number of lines) the last
line isn't counted.
First of all, I do not know if it is really a bug, because a
newline must end with a '\n' char. But assume a file, that the
last line does not end with a '\n', so the last line does not
exist ?!
Summarizing:
The problem is: if the input does not end with a newline "\n",
this line is not counted. The classic example:
$ echo -n 'Test line' | wc -l
0
This patch below solve the problem.
PS: coreutils-5.0
HTH,
thobias
-------
echo 133449562074222244746332132269002206986P | dc
-------
http://thobias.org
--- old_wc.c 2004-02-06 08:39:16.000000000 -0200
+++ wc.c 2004-02-06 09:25:52.000000000 -0200
@@ -276,6 +276,9 @@
}
bytes += bytes_read;
}
+ /* input might not end with a newline */
+ if ((buf[strlen(buf)-1]) != '\n')
+ ++lines;
}
#if HAVE_MBRTOWC && (MB_LEN_MAX > 1)
# define SUPPORT_OLD_MBRTOWC 1
_______________________________________________
Bug-coreutils mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-coreutils