[hackers] [sbase] wc: Print number of bytes by default || Dionysis Grigoropoulos

From: <git_AT_suckless.org>
Date: Sun, 5 Apr 2015 10:14:04 +0200 (CEST)

commit feb77a3b8db8dcba78c695a1cda5104323c4536f
Author: Dionysis Grigoropoulos <info_AT_erethon.com>
Date: Sun Apr 5 01:57:30 2015 +0300

    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

diff --git a/wc.c b/wc.c
index ed2c94d..e57cb4c 100644
--- a/wc.c
+++ b/wc.c
_AT_@ -32,7 +32,7 @@ wc(FILE *fp, const char *str)
         size_t nc = 0, nl = 0, nw = 0;
 
         while ((rlen = efgetrune(&c, fp, str))) {
- nc += (cmode == 'c') ? rlen :
+ nc += (cmode == 'c' || !cmode) ? rlen :
                       (c != Runeerror) ? 1 : 0;
                 if (c == '\n')
                         nl++;
Received on Sun Apr 05 2015 - 10:14:04 CEST

This archive was generated by hypermail 2.3.0 : Sun Apr 05 2015 - 10:24:17 CEST