bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

move fpurge to <stdio.h>


From: Eric Blake
Subject: move fpurge to <stdio.h>
Date: Wed, 24 Jun 2009 06:52:29 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.22) Gecko/20090605 Thunderbird/2.0.0.22 Mnenhy/0.7.6.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Any objections to this patch?  I know that many of the stdio extensions,
such as freading, should stay in their own header, since they are gnulib
extensions not found in any system.  But several systems provide fpurge
directly in <stdio.h> (and I'm working on adding it for cygwin 1.7 as
well), so even though glibc does not provide it (it only provides __fpurge
in <stdio_ext.h>), I think that <stdio.h> is a better fit than "fpurge.h".

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkpCIY0ACgkQ84KuGfSFAYAQdgCggxCcq0bWo08SqN+Zbn/nN8Dr
BhUAnjrF67feiILPcbsbSnDUk9CWPD3S
=v6MT
-----END PGP SIGNATURE-----
>From d8715b00791681bd7abc872882dea6882dfed1e2 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Wed, 24 Jun 2009 06:49:00 -0600
Subject: [PATCH] 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.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog           |   16 ++++++++++++++++
 NEWS                |    3 +++
 lib/fflush.c        |    1 -
 lib/fpurge.c        |    2 +-
 lib/fpurge.h        |   38 --------------------------------------
 lib/stdio.in.h      |   18 +++++++++++++++++-
 m4/fpurge.m4        |   14 +++++++++++---
 m4/stdio_h.m4       |    5 ++++-
 modules/fpurge      |    5 +++--
 modules/stdio       |    3 +++
 tests/test-fpurge.c |    5 ++---
 11 files changed, 60 insertions(+), 50 deletions(-)
 delete mode 100644 lib/fpurge.h

diff --git a/ChangeLog b/ChangeLog
index 8aa5ac0..f0115dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2009-06-24  Eric Blake  <address@hidden>
+
+       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-24  Bruno Haible  <address@hidden>

        * m4/lib-link.m4 (AC_LIB_HAVE_LINKFLAGS): Fix description of
diff --git a/NEWS b/NEWS
index 005fa7e..7a4e987 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,9 @@ User visible incompatible changes

 Date        Modules         Changes

+2009-06-24  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
diff --git a/lib/fflush.c b/lib/fflush.c
index 9f75ccd..7c6085c 100644
--- a/lib/fflush.c
+++ b/lib/fflush.c
@@ -25,7 +25,6 @@
 #include <unistd.h>

 #include "freading.h"
-#include "fpurge.h"

 #include "stdio-impl.h"

diff --git a/lib/fpurge.c b/lib/fpurge.c
index 5e0d47d..dc64147 100644
--- a/lib/fpurge.c
+++ b/lib/fpurge.c
@@ -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
index d7150a1..0000000
--- a/lib/fpurge.h
+++ /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 */
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index ba63f2c..a122d6d 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -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,22 @@ extern long rpl_ftell (FILE *fp);
     fflush (f))
 #endif

+#if @GNULIB_FPURGE@
+# if @REPLACE_FPURGE@
+#  define fpurge rpl_fpurge
+# endif
+# if @REPLACE_FPURGE@ || address@hidden@
+  /* Discard all pending data on STREAM.  */
+  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
diff --git a/m4/fpurge.m4 b/m4/fpurge.m4
index 796b66c..1c3ca10 100644
--- a/m4/fpurge.m4
+++ b/m4/fpurge.m4
@@ -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
 ])
diff --git a/m4/stdio_h.m4 b/m4/stdio_h.m4
index 846b65d..fcbe68f 100644
--- a/m4/stdio_h.m4
+++ b/m4/stdio_h.m4
@@ -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])
diff --git a/modules/fpurge b/modules/fpurge
index d384d7e..1caa67d 100644
--- a/modules/fpurge
+++ b/modules/fpurge
@@ -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
diff --git a/modules/stdio b/modules/stdio
index dd2eccb..87308a6 100644
--- a/modules/stdio
+++ b/modules/stdio
@@ -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' \
diff --git a/tests/test-fpurge.c b/tests/test-fpurge.c
index 280da99..75a75c9 100644
--- a/tests/test-fpurge.c
+++ b/tests/test-fpurge.c
@@ -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>

-- 
1.6.3.3.334.g916e1


reply via email to

[Prev in Thread] Current Thread [Next in Thread]