On Tue, Mar 17, 2015 at 11:35:33AM +0100, Roberto E. Vargas Caballero wrote:
>
> Hi,
>
> > + for (p = str, col = 0; *p && *p != '\n'; p++) {
> > + if (!UTF8_POINT(*p) && !bflag)
> > + continue;
> > + if (col >= width) {
> > + off = (sflag && spacesect) ? spacesect - str : p - str;
> > + if (fwrite(str, 1, off, stdout) != off)
> > + eprintf("fwrite <stdout>:");
> > + putchar('\n');
> ...
> > + fputs(str, stdout);
>
> It's a bit strange this fwrite, why don't you use putchar there?, and
> why you check the return value of fwrite, but not the return value of
> putcharor fputs?. I usually don't check the return value of write
> functions and at the end of the loop I do a call to ferror.
If fwrite() fails with a short element count, will ferror() always be
on true? I am not sure we can rely on this.
And also if fwrite() fails is it guaranteed that it will continue to
fail on all future calls?