From 6df4fc403dd3994c714e9154c7ad533125ee1e8c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rainer=20M=C3=BCller?= Date: Wed, 20 Feb 2013 20:10:40 +0100 Subject: [PATCH] configure: Check for stdio_ext.h For portability, check for stdio_ext.h during configure and define HAVE_STDIO_EXT_H accordingly. If the current system does not provide this header, use a fallback for __fpending(). This definition will not work on all systems as it relies on internal data structures of libc. A more portable solution should be preferred, for example by using gnulib. --- configure.ac | 2 ++ lib/fileutils.c | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index afb24cee..08f59e3d 100644 --- a/configure.ac +++ b/configure.ac @@ -137,6 +137,8 @@ dnl else dnl ALL_LINGUAS="af am ar as be bg bn_IN bn ca cs cy da de el en_GB es et eu_ES fa fi fr gl gu he hi hr hu hy id is it ja ka kn ko ku lo lt lv mk ml mr ms my nb nl nn no nso or pa pl pt_BR pt ro ru si sk sl sq sr@Latn sr sv ta te th tr uk ur vi zh_CN zh_TW zu" dnl fi +AC_CHECK_HEADERS(stdio_ext.h, [], [], AC_INCLUDES_DEFAULT) + AC_MSG_CHECKING(whether program_invocation_name is defined) AC_TRY_COMPILE([#include ], [program_invocation_name = "test";], diff --git a/lib/fileutils.c b/lib/fileutils.c index fe56cb81..c50d6aa9 100644 --- a/lib/fileutils.c +++ b/lib/fileutils.c @@ -1,6 +1,12 @@ #include #include -#include +#ifdef HAVE_STDIO_EXT_H +# include +#else +/* FIXME: use a more portable definition of __fpending() (from gnulib?) */ +# include +# define __fpending(fp) ((fp)->_p - (fp)->_bf._base) +#endif #include #include -- 2.40.0