fpurge: migrate into <stdio.h>
authorEric Blake <ebb9@byu.net>
Wed, 24 Jun 2009 12:49:00 +0000 (06:49 -0600)
committerEric Blake <ebb9@byu.net>
Thu, 25 Jun 2009 12:43:30 +0000 (06:43 -0600)
* lib/fpurge.h: Delete...
* lib/stdio.in.h (fpurge): ...and declare here, instead.
* lib/fpurge.c (fpurge): Change declaring header.
* modules/fpurge (Files): Drop deleted file.
(Depends-on): Add stdio.
(configure.ac): Set witness.
* modules/stdio (Makefile.am): Support fpurge macros.
* m4/stdio_h.m4 (gl_STDIO_H_DEFAULTS): Likewise.
* m4/fpurge.m4 (gl_FUNC_FPURGE): Set appropriate variables.
* lib/fflush.c: Update client.
* tests/test-fpurge.c: Likewise.
* NEWS: Mention the change.

Signed-off-by: Eric Blake <ebb9@byu.net>
ChangeLog
NEWS
lib/fflush.c
lib/fpurge.c
lib/fpurge.h [deleted file]
lib/stdio.in.h
m4/fpurge.m4
m4/stdio_h.m4
modules/fpurge
modules/stdio
tests/test-fpurge.c

index 5faaa7f..fc5719b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2009-06-25  Eric Blake  <ebb9@byu.net>
+
+       fpurge: migrate into <stdio.h>
+       * lib/fpurge.h: Delete...
+       * lib/stdio.in.h (fpurge): ...and declare here, instead.
+       * lib/fpurge.c (fpurge): Change declaring header.
+       * modules/fpurge (Files): Drop deleted file.
+       (Depends-on): Add stdio.
+       (configure.ac): Set witness.
+       * modules/stdio (Makefile.am): Support fpurge macros.
+       * m4/stdio_h.m4 (gl_STDIO_H_DEFAULTS): Likewise.
+       * m4/fpurge.m4 (gl_FUNC_FPURGE): Set appropriate variables.
+       * lib/fflush.c: Update client.
+       * tests/test-fpurge.c: Likewise.
+       * NEWS: Mention the change.
+
 2009-06-25  Sergey Poznyakoff  <gray@gnu.org.ua>
 
        * lib/argp-version-etc.c (program_authors): Add const
diff --git a/NEWS b/NEWS
index 005fa7e..5989bd9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,9 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2009-06-25  fpurge          The include file is changed from "fpurge.h" to
+                            <stdio.h>.
+
 2009-04-26  modules/uniconv/u8-conv-from-enc
             modules/uniconv/u16-conv-from-enc
             modules/uniconv/u32-conv-from-enc
index 9f75ccd..7c6085c 100644 (file)
@@ -25,7 +25,6 @@
 #include <unistd.h>
 
 #include "freading.h"
-#include "fpurge.h"
 
 #include "stdio-impl.h"
 
index 5e0d47d..dc64147 100644 (file)
@@ -17,7 +17,7 @@
 #include <config.h>
 
 /* Specification.  */
-#include "fpurge.h"
+#include <stdio.h>
 
 #if HAVE___FPURGE                   /* glibc >= 2.2, Haiku, Solaris >= 7 */
 # include <stdio_ext.h>
diff --git a/lib/fpurge.h b/lib/fpurge.h
deleted file mode 100644 (file)
index d7150a1..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Flushing buffers of a FILE stream.
-   Copyright (C) 2007 Free Software Foundation, Inc.
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-#ifndef _GL_FPURGE_H
-#define _GL_FPURGE_H
-
-#include <stdio.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Discard all pending buffered I/O on the stream STREAM.
-   STREAM must not be wide-character oriented.
-   Return 0 if successful.  Upon error, return -1 and set errno.  */
-#if HAVE_FPURGE
-# define fpurge rpl_fpurge
-#endif
-extern int fpurge (FILE *stream);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _GL_FPURGE_H */
index ba63f2c..78e35d5 100644 (file)
@@ -1,6 +1,6 @@
 /* A GNU-like <stdio.h>.
 
-   Copyright (C) 2004, 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2007-2009 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -407,6 +407,24 @@ extern long rpl_ftell (FILE *fp);
     fflush (f))
 #endif
 
+#if @GNULIB_FPURGE@
+# if @REPLACE_FPURGE@
+#  define fpurge rpl_fpurge
+# endif
+# if @REPLACE_FPURGE@ || !@HAVE_DECL_FPURGE@
+  /* Discard all pending buffered I/O data on STREAM.
+     STREAM must not be wide-character oriented.
+     Return 0 if successful.  Upon error, return -1 and set errno.  */
+  extern int fpurge (FILE *gl_stream);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef fpurge
+# define fpurge(f) \
+   (GL_LINK_WARNING ("fpurge is not always present - " \
+                     "use gnulib module fpurge for portability"), \
+    fpurge (f))
+#endif
+
 #if @GNULIB_FCLOSE@
 # if @REPLACE_FCLOSE@
 #  define fclose rpl_fclose
index 796b66c..1c3ca10 100644 (file)
@@ -1,12 +1,20 @@
-# fpurge.m4 serial 2
-dnl Copyright (C) 2007 Free Software Foundation, Inc.
+# fpurge.m4 serial 3
+dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_FUNC_FPURGE],
 [
+  AC_REQUIRE([gl_STDIO_H_DEFAULTS])
   AC_CHECK_FUNCS_ONCE([fpurge])
   AC_CHECK_FUNCS_ONCE([__fpurge])
-  AC_CHECK_DECLS([fpurge], , , [#include <stdio.h>])
+  AC_CHECK_DECLS([fpurge], , , [[#include <stdio.h>]])
+  dnl For now, lib/fpurge.c is always compiled.
+  if test "x$ac_cv_func_fpurge" = xyes; then
+    REPLACE_FPURGE=1
+  fi
+  if test "x$ac_cv_have_decl_fpurge" = xno; then
+    HAVE_DECL_FPURGE=0
+  fi
 ])
index 846b65d..fcbe68f 100644 (file)
@@ -1,4 +1,4 @@
-# stdio_h.m4 serial 15
+# stdio_h.m4 serial 16
 dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -65,6 +65,7 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
   GNULIB_FTELL=0;                AC_SUBST([GNULIB_FTELL])
   GNULIB_FTELLO=0;               AC_SUBST([GNULIB_FTELLO])
   GNULIB_FFLUSH=0;               AC_SUBST([GNULIB_FFLUSH])
+  GNULIB_FPURGE=0;               AC_SUBST([GNULIB_FPURGE])
   GNULIB_FCLOSE=0;               AC_SUBST([GNULIB_FCLOSE])
   GNULIB_FPUTC=0;                AC_SUBST([GNULIB_FPUTC])
   GNULIB_PUTC=0;                 AC_SUBST([GNULIB_PUTC])
@@ -105,6 +106,8 @@ AC_DEFUN([gl_STDIO_H_DEFAULTS],
   REPLACE_FTELLO=0;              AC_SUBST([REPLACE_FTELLO])
   REPLACE_FTELL=0;               AC_SUBST([REPLACE_FTELL])
   REPLACE_FFLUSH=0;              AC_SUBST([REPLACE_FFLUSH])
+  REPLACE_FPURGE=0;              AC_SUBST([REPLACE_FPURGE])
+  HAVE_DECL_FPURGE=1;            AC_SUBST([HAVE_DECL_FPURGE])
   REPLACE_FCLOSE=0;              AC_SUBST([REPLACE_FCLOSE])
   HAVE_DECL_GETDELIM=1;          AC_SUBST([HAVE_DECL_GETDELIM])
   HAVE_DECL_GETLINE=1;           AC_SUBST([HAVE_DECL_GETLINE])
index d384d7e..1caa67d 100644 (file)
@@ -2,21 +2,22 @@ Description:
 fpurge() function: Flush buffers.
 
 Files:
-lib/fpurge.h
 lib/fpurge.c
 lib/stdio-impl.h
 m4/fpurge.m4
 
 Depends-on:
+stdio
 
 configure.ac:
 gl_FUNC_FPURGE
+gl_STDIO_MODULE_INDICATOR([fpurge])
 
 Makefile.am:
 lib_SOURCES += fpurge.c
 
 Include:
-"fpurge.h"
+<stdio.h>
 
 License:
 LGPL
index dd2eccb..87308a6 100644 (file)
@@ -49,6 +49,7 @@ stdio.h: stdio.in.h
              -e 's|@''GNULIB_FTELL''@|$(GNULIB_FTELL)|g' \
              -e 's|@''GNULIB_FTELLO''@|$(GNULIB_FTELLO)|g' \
              -e 's|@''GNULIB_FFLUSH''@|$(GNULIB_FFLUSH)|g' \
+             -e 's|@''GNULIB_FPURGE''@|$(GNULIB_FPURGE)|g' \
              -e 's|@''GNULIB_FCLOSE''@|$(GNULIB_FCLOSE)|g' \
              -e 's|@''GNULIB_FPUTC''@|$(GNULIB_FPUTC)|g' \
              -e 's|@''GNULIB_PUTC''@|$(GNULIB_PUTC)|g' \
@@ -86,6 +87,8 @@ stdio.h: stdio.in.h
              -e 's|@''REPLACE_FTELLO''@|$(REPLACE_FTELLO)|g' \
              -e 's|@''REPLACE_FTELL''@|$(REPLACE_FTELL)|g' \
              -e 's|@''REPLACE_FFLUSH''@|$(REPLACE_FFLUSH)|g' \
+             -e 's|@''REPLACE_FPURGE''@|$(REPLACE_FPURGE)|g' \
+             -e 's|@''HAVE_DECL_FPURGE''@|$(HAVE_DECL_FPURGE)|g' \
              -e 's|@''REPLACE_FCLOSE''@|$(REPLACE_FCLOSE)|g' \
              -e 's|@''HAVE_DECL_GETDELIM''@|$(HAVE_DECL_GETDELIM)|g' \
              -e 's|@''HAVE_DECL_GETLINE''@|$(HAVE_DECL_GETLINE)|g' \
index 280da99..75a75c9 100644 (file)
@@ -1,5 +1,5 @@
 /* Test of fpurge() function.
-   Copyright (C) 2007-2008 Free Software Foundation, Inc.
+   Copyright (C) 2007-2009 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -18,9 +18,8 @@
 
 #include <config.h>
 
-#include "fpurge.h"
-
 #include <stdio.h>
+
 #include <stdlib.h>
 #include <string.h>