Re: [hackers] [sbase] [PATCH 2/3] find: Fix flushing input buffer with -ok

From: Evan Gates <evan.gates_AT_gmail.com>
Date: Mon, 15 Jun 2015 13:09:49 -0700

On Mon, Jun 15, 2015 at 12:27 PM, Wolfgang Corcoran-Mathe
<first.lord.of.teal_AT_gmail.com> wrote:
> emg's FIXME about nulls still applies.
>
> /* throw away rest of line */
> - while (fgets(buf, sizeof(buf), stdin) && *buf && buf[strlen(buf) - 1] == '\n')
> + while ((c = fgetc(stdin)) != '\n' && c != EOF)
> /* FIXME: what if the first character of the rest of the line is a null
> - * byte? probably shouldn't juse fgets() */
> + * byte? */
> ;

Nope, not a problem anymore as you're explicitly checking against '\n'
and EOF so reading a '\0' is fine. Much better than the fgets.

-emg
Received on Mon Jun 15 2015 - 22:09:49 CEST

This archive was generated by hypermail 2.3.0 : Thu Jun 18 2015 - 17:37:21 CEST