summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorG.raud Meyer2018-04-05 11:50:07 +0200
committerG.raud Meyer2018-04-09 17:21:17 +0200
commit0dba6b6f195aceafd1afefc2c2515ce0d8c707ad (patch)
tree38a5becc31278e7b755724d870327f99fa2692fc
parentrename: ask(): call __fpurge() to cater for multi-byte characters (diff)
downloadkernel-qcow2-util-linux-0dba6b6f195aceafd1afefc2c2515ce0d8c707ad.tar.gz
kernel-qcow2-util-linux-0dba6b6f195aceafd1afefc2c2515ce0d8c707ad.tar.xz
kernel-qcow2-util-linux-0dba6b6f195aceafd1afefc2c2515ce0d8c707ad.zip
rename: test availability of __fpurge() and fpurge()
-rw-r--r--configure.ac2
-rw-r--r--misc-utils/rename.c10
2 files changed, 11 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 3ad35abec..2a8d4e490 100644
--- a/configure.ac
+++ b/configure.ac
@@ -449,6 +449,8 @@ AC_CHECK_DECL([SO_PASSCRED],
#include <sys/socket.h>])
AC_CHECK_FUNCS([ \
+ __fpurge \
+ fpurge \
__fpending \
secure_getenv \
__secure_getenv \
diff --git a/misc-utils/rename.c b/misc-utils/rename.c
index c9add7780..2bbf7589a 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 <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')