wc: Print number of bytes by default

According to POSIX, wc should by default print the number of bytes and
not the number of chars
This commit is contained in:
Dionysis Grigoropoulos 2015-04-05 01:57:30 +03:00 committed by sin
parent 3eee8e1509
commit feb77a3b8d

2
wc.c
View File

@ -32,7 +32,7 @@ wc(FILE *fp, const char *str)
size_t nc = 0, nl = 0, nw = 0; size_t nc = 0, nl = 0, nw = 0;
while ((rlen = efgetrune(&c, fp, str))) { while ((rlen = efgetrune(&c, fp, str))) {
nc += (cmode == 'c') ? rlen : nc += (cmode == 'c' || !cmode) ? rlen :
(c != Runeerror) ? 1 : 0; (c != Runeerror) ? 1 : 0;
if (c == '\n') if (c == '\n')
nl++; nl++;