From 26012822ac6fb1c8064bed35e92f93b0cbce44a8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rainer=20M=C3=BCller?= <raimue@codingfarm.de>
Date: Wed, 20 Feb 2013 20:10:40 +0100
Subject: [PATCH 3/4] 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 afb24ce..08f59e3 100644
a
|
b
|
dnl else |
137 | 137 | 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" |
138 | 138 | dnl fi |
139 | 139 | |
| 140 | AC_CHECK_HEADERS(stdio_ext.h, [], [], AC_INCLUDES_DEFAULT) |
| 141 | |
140 | 142 | AC_MSG_CHECKING(whether program_invocation_name is defined) |
141 | 143 | AC_TRY_COMPILE([#include <errno.h>], |
142 | 144 | [program_invocation_name = "test";], |
diff --git a/lib/fileutils.c b/lib/fileutils.c
index fe56cb8..c50d6aa 100644
a
|
b
|
|
1 | 1 | #include <errno.h> |
2 | 2 | #include <error.h> |
3 | | #include <stdio_ext.h> |
| 3 | #ifdef HAVE_STDIO_EXT_H |
| 4 | # include <stdio_ext.h> |
| 5 | #else |
| 6 | /* FIXME: use a more portable definition of __fpending() (from gnulib?) */ |
| 7 | # include <stdio.h> |
| 8 | # define __fpending(fp) ((fp)->_p - (fp)->_bf._base) |
| 9 | #endif |
4 | 10 | #include <stdlib.h> |
5 | 11 | #include <unistd.h> |
6 | 12 | |