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:
parent
3eee8e1509
commit
feb77a3b8d
2
wc.c
2
wc.c
|
@ -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++;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user