Flushing `stdin` is undefined behaviour.
References
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf, chapter 7.21.5.2 (The fflush function)
http://en.cppreference.com/w/c/io/fflush
mutt_error("%s: %s (errno = %d)", s, p ? p : _("unknown error"), errno);
}
+/**
+ * mutt_flush_stdin - remove characters from stdin until '\n' or EOF is encountered
+ */
+void mutt_flush_stdin(void)
+{
+ int c;
+ do
+ {
+ c = fgetc(stdin);
+ } while ((c != '\n') && (c != EOF));
+}
+
+
/**
* mutt_any_key_to_continue - Prompt the user to 'press any key' and wait
* @param s Message prompt
fputs(_("Press any key to continue..."), stdout);
fflush(stdout);
int ch = fgetc(stdin);
- fflush(stdin);
+ mutt_flush_stdin();
tcsetattr(fd, TCSADRAIN, &old);
close(fd);
fputs("\r\n", stdout);