implement the nonstandard GNU function fpurge
authorRich Felker <dalias@aerifal.cx>
Thu, 30 Jun 2011 15:42:33 +0000 (11:42 -0400)
committerRich Felker <dalias@aerifal.cx>
Thu, 30 Jun 2011 15:42:33 +0000 (11:42 -0400)
this is a really ugly and backwards function, but its presence will
prevent lots of broken gnulib software from trying to define its own
version of fpurge and thereby failing to build or worse.

include/stdio.h
src/stdio/fpurge.c [new file with mode: 0644]

index 69178cc..b54fe19 100644 (file)
@@ -158,6 +158,7 @@ int asprintf(char **, const char *, ...);
 int vasprintf(char **, const char *, va_list);
 void setlinebuf(FILE *);
 void setbuffer(FILE *, char *, size_t);
+int fpurge(FILE *);
 #endif
 
 #ifdef __cplusplus
diff --git a/src/stdio/fpurge.c b/src/stdio/fpurge.c
new file mode 100644 (file)
index 0000000..a9e98e7
--- /dev/null
@@ -0,0 +1,11 @@
+#define _GNU_SOURCE
+#include "stdio_impl.h"
+
+int __fpurge(FILE *f)
+{
+       f->wpos = f->wbase = f->wend = 0;
+       f->rpos = f->rend = 0;
+       return 0;
+}
+
+weak_alias(__fpurge, fpurge);