From 06bb7353974603cd49911015f704d65e004bd6d4 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 5 Dec 2015 16:58:06 +0100 Subject: m + bug fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/echoes.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/echoes.c b/src/echoes.c index e0a18f4..7274e52 100644 --- a/src/echoes.c +++ b/src/echoes.c @@ -25,12 +25,22 @@ -#if !defined(PASSPHRASE_ECHO) || defined(PASSPHRASE_MOVE) +#if !defined(PASSPHRASE_ECHO) || defined(PASSPHRASE_MOVE) || defined(PASSPHRASE_METER) +# define NEED_TERMIOS +#else +# ifdef NEED_TERMIOS +# undef NEED_TERMIOS +# endif +#endif /* !PASSPHRASE_ECHO || PASSPHRASE_MOVE || PASSPHRASE_METER */ + + + +#if defined(NEED_TERMIOS) /** * The original TTY settings */ static struct termios saved_stty; -#endif /* !PASSPHRASE_ECHO || PASSPHRASE_MOVE */ +#endif /* NEED_TERMIOS */ @@ -56,9 +66,12 @@ void passphrase_reenable_echo(void) * * @param fdin File descriptor for input */ +#if defined(__GNUC__) && !defined(NEED_TERMIOS) +__attribute__((const)) +#endif /* __GNUC__ && !NEED_TERMIOS */ void passphrase_disable_echo1(int fdin) { -#if !defined(PASSPHRASE_ECHO) || defined(PASSPHRASE_MOVE) || defined(PASSPHRASE_METER) +#if defined(NEED_TERMIOS) struct termios stty; tcgetattr(fdin, &stty); @@ -68,9 +81,9 @@ void passphrase_disable_echo1(int fdin) stty.c_lflag &= (tcflag_t)~ICANON; # endif /* PASSPHRASE_STAR || PASSPHRASE_TEXT || PASSPHRASE_MOVE || PASSPHRASE_METER */ tcsetattr(fdin, TCSAFLUSH, &stty); -#else /* !PASSPHRASE_ECHO || PASSPHRASE_MOVE || PASSPHRASE_METER */ +#else /* NEED_TERMIOS */ (void) fdin; -#endif /* !PASSPHRASE_ECHO || PASSPHRASE_MOVE || PASSPHRASE_METER */ +#endif /* NEED_TERMIOS */ } @@ -79,12 +92,15 @@ void passphrase_disable_echo1(int fdin) * * @param fdin File descriptor for input */ +#if defined(__GNUC__) && !defined(NEED_TERMIOS) +__attribute__((const)) +#endif /* __GNUC__ && !NEED_TERMIOS */ void passphrase_reenable_echo1(int fdin) { -#if !defined(PASSPHRASE_ECHO) || defined(PASSPHRASE_MOVE) || defined(PASSPHRASE_METER) +#if defined(NEED_TERMIOS) tcsetattr(fdin, TCSAFLUSH, &saved_stty); -#else /* !PASSPHRASE_ECHO || !PASSPHRASE_MOVE || PASSPHRASE_METER */ +#else /* NEED_TERMIOS */ (void) fdin; -#endif /* !PASSPHRASE_ECHO || !PASSPHRASE_MOVE || PASSPHRASE_METER */ +#endif /* NEED_TERMIOS */ } -- cgit v1.2.3-70-g09d2