From: G.raud Meyer Date: Thu, 5 Apr 2018 09:50:07 +0000 (+0200) Subject: rename: test availability of __fpurge() and fpurge() X-Git-Tag: v2.33-rc1~309^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0dba6b6f195aceafd1afefc2c2515ce0d8c707ad;p=thirdparty%2Futil-linux.git rename: test availability of __fpurge() and fpurge() --- diff --git a/configure.ac b/configure.ac index 3ad35abecf..2a8d4e4906 100644 --- a/configure.ac +++ b/configure.ac @@ -449,6 +449,8 @@ AC_CHECK_DECL([SO_PASSCRED], #include ]) AC_CHECK_FUNCS([ \ + __fpurge \ + fpurge \ __fpending \ secure_getenv \ __secure_getenv \ diff --git a/misc-utils/rename.c b/misc-utils/rename.c index c9add77803..2bbf7589ae 100644 --- a/misc-utils/rename.c +++ b/misc-utils/rename.c @@ -14,7 +14,13 @@ for i in $@; do N=`echo "$i" | sed "s/$FROM/$TO/g"`; mv "$i" "$N"; done * in cases involving special characters. Here a C version. */ #include -#include +#ifdef HAVE_STDIO_EXT_H +# include +#endif +#ifdef HAVE_FPURGE +# define HAVE___FPURGE 1 +# define __fpurge fpurge +#endif #include #include #include @@ -73,12 +79,14 @@ static int ask(char *name) else { buf[0] = c; if (c != '\n' && tty_cbreak) { +#ifdef HAVE___FPURGE /* Possibly purge a multi-byte character; or do a required purge of the rest of the line (including the newline) if the tty has been put back in canonical mode (for example by a shell after a SIGTSTP signal). */ __fpurge(stdin); +#endif printf("\n"); } else if (c != '\n')