From 6e3876a5a6800e289d34b107bddf71f17c641694 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 1 Dec 2012 00:42:01 -0600 Subject: Felix Janda pointed out that the r in mbrtowc() stands for "restartable" so it's already buffering the partial data we feed it, so rolling back most of the last commit to wc. --- toys/posix/wc.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'toys/posix/wc.c') diff --git a/toys/posix/wc.c b/toys/posix/wc.c index d6029b6e..a9c588e8 100644 --- a/toys/posix/wc.c +++ b/toys/posix/wc.c @@ -51,30 +51,25 @@ static void do_wc(int fd, char *name) unsigned long word=0, lengths[]={0,0,0}; for (;;) { - i = 0; -again: - len = i+read(fd, toybuf+i, sizeof(toybuf)-i); - if (len < i) { + len = read(fd, toybuf, sizeof(toybuf)); + if (len<0) { perror_msg("%s",name); toys.exitval = 1; } - if (!len) break; + if (len<1) break; for (i=0; i