Re: [hackers] [sbase] Rewrite foldline() in fold(1) || FRIGN

From: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Tue, 17 Mar 2015 11:35:33 +0100

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.


Regards,
Received on Tue Mar 17 2015 - 11:35:33 CET

This archive was generated by hypermail 2.3.0 : Tue Mar 17 2015 - 11:36:11 CET