From 0d626a9b7c58a25b292252357f5a91110024cfaa Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 24 Jun 2009 06:49:00 -0600 Subject: [PATCH] fpurge: migrate into * 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 --- ChangeLog | 16 ++++++++++++++++ NEWS | 3 +++ lib/fflush.c | 1 - lib/fpurge.c | 2 +- lib/fpurge.h | 38 -------------------------------------- lib/stdio.in.h | 20 +++++++++++++++++++- m4/fpurge.m4 | 14 +++++++++++--- m4/stdio_h.m4 | 5 ++++- modules/fpurge | 5 +++-- modules/stdio | 3 +++ tests/test-fpurge.c | 5 ++--- 11 files changed, 62 insertions(+), 50 deletions(-) delete mode 100644 lib/fpurge.h diff --git a/ChangeLog b/ChangeLog index 5faaa7f96..fc5719b07 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2009-06-25 Eric Blake + + fpurge: migrate into + * 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 * lib/argp-version-etc.c (program_authors): Add const diff --git a/NEWS b/NEWS index 005fa7e8c..5989bd91d 100644 --- 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 + . + 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 9f75ccdc1..7c6085cfd 100644 --- a/lib/fflush.c +++ b/lib/fflush.c @@ -25,7 +25,6 @@ #include #include "freading.h" -#include "fpurge.h" #include "stdio-impl.h" diff --git a/lib/fpurge.c b/lib/fpurge.c index 5e0d47dda..dc6414778 100644 --- a/lib/fpurge.c +++ b/lib/fpurge.c @@ -17,7 +17,7 @@ #include /* Specification. */ -#include "fpurge.h" +#include #if HAVE___FPURGE /* glibc >= 2.2, Haiku, Solaris >= 7 */ # include diff --git a/lib/fpurge.h b/lib/fpurge.h deleted file mode 100644 index d7150a1a6..000000000 --- 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 . */ - -#ifndef _GL_FPURGE_H -#define _GL_FPURGE_H - -#include - -#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 ba63f2cc1..78e35d57b 100644 --- a/lib/stdio.in.h +++ b/lib/stdio.in.h @@ -1,6 +1,6 @@ /* A GNU-like . - 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 diff --git a/m4/fpurge.m4 b/m4/fpurge.m4 index 796b66c6c..1c3ca1033 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 ]) + AC_CHECK_DECLS([fpurge], , , [[#include ]]) + 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 846b65d30..fcbe68f6b 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 d384d7ee0..1caa67dee 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" + License: LGPL diff --git a/modules/stdio b/modules/stdio index dd2eccb50..87308a6ab 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 280da991b..75a75c9dc 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 -#include "fpurge.h" - #include + #include #include -- 2.11.0