]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
rename: test availability of __fpurge() and fpurge()
authorG.raud Meyer <graud@gmx.com>
Thu, 5 Apr 2018 09:50:07 +0000 (11:50 +0200)
committerG.raud Meyer <graud@gmx.com>
Mon, 9 Apr 2018 15:21:17 +0000 (17:21 +0200)
configure.ac
misc-utils/rename.c

index 3ad35abecfa218dec19155bbd2b80a41a255b611..2a8d4e4906e41e2ea2dcf5a9aae8e92a4c65ccab 100644 (file)
@@ -449,6 +449,8 @@ AC_CHECK_DECL([SO_PASSCRED],
                #include <sys/socket.h>])
 
 AC_CHECK_FUNCS([ \
+       __fpurge \
+       fpurge \
        __fpending \
        secure_getenv \
        __secure_getenv \
index c9add77803b05a41b332ce13557368f5012615cf..2bbf7589ae85fe906d9704da3bea58e504fe0e71 100644 (file)
@@ -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 <stdio.h>
-#include <stdio_ext.h>
+#ifdef HAVE_STDIO_EXT_H
+#      include <stdio_ext.h>
+#endif
+#ifdef HAVE_FPURGE
+#      define HAVE___FPURGE 1
+#      define __fpurge fpurge
+#endif
 #include <string.h>
 #include <stdlib.h>
 #include <errno.h>
@@ -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')