fflush stdin in actsync

Richard Kettlewell rjk at terraraq.org.uk
Sun Apr 3 11:55:02 UTC 2016


On 2016-04-03 07:58, Julien ÉLIE wrote:
> Hi all,
> 
> In backends/actsync.c, we use "fflush(stdin)" that has undefined
> behaviour (portability issue).
> Has someone ever encountered an issue with actsync because of that?
> 
> Is it worth trying to fix it?  (using scanf for instance and discarding
> output)
> 

It's undefined in C99 but has defined behavior in SUS:

For a stream open for reading, if the file is not already at EOF, and
the file is one capable of seeking, the file offset of the underlying
open file description shall be set to the file position of the stream,
and any characters pushed back onto the stream by ungetc() or ungetwc()
that have not subsequently been read from the stream shall be discarded
(without further changing the file offset)

http://pubs.opengroup.org/onlinepubs/9699919799/functions/fflush.html

So it depends what the portability goal is.

ttfn/rjk



More information about the inn-workers mailing list