summaryrefslogtreecommitdiff
path: root/m4/btowc.m4
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2008-12-21 17:35:30 +0100
committerBruno Haible <bruno@clisp.org>2008-12-21 17:35:30 +0100
commit222bd6c8493f3392c15db8cb3fe2e382063727d4 (patch)
tree8c89272da7a9df1a6a669fe0d37f0ad93432d5b5 /m4/btowc.m4
parent3679dd2c6191c9872d0ffeced51e711f26099d65 (diff)
downloadgnulib-222bd6c8493f3392c15db8cb3fe2e382063727d4.tar.gz
Work around a btowc() bug on IRIX 6.5.
Diffstat (limited to 'm4/btowc.m4')
-rw-r--r--m4/btowc.m447
1 files changed, 46 insertions, 1 deletions
diff --git a/m4/btowc.m4 b/m4/btowc.m4
index a53694acd6..64ff829061 100644
--- a/m4/btowc.m4
+++ b/m4/btowc.m4
@@ -1,4 +1,4 @@
-# btowc.m4 serial 2
+# btowc.m4 serial 3
dnl Copyright (C) 2008 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
@@ -11,6 +11,51 @@ AC_DEFUN([gl_FUNC_BTOWC],
AC_CHECK_FUNCS_ONCE([btowc])
if test $ac_cv_func_btowc = no; then
HAVE_BTOWC=0
+ else
+
+ dnl IRIX 6.5 btowc(EOF) is 0xFF, not WEOF.
+ AC_REQUIRE([AC_PROG_CC])
+ AC_REQUIRE([gt_LOCALE_FR])
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
+ AC_CACHE_CHECK([whether btowc(EOF) is correct],
+ [gl_cv_func_btowc_eof],
+ [
+ dnl Initial guess, used when cross-compiling or when no suitable locale
+ dnl is present.
+changequote(,)dnl
+ case "$host_os" in
+ # Guess no on IRIX.
+ irix*) gl_cv_func_btowc_eof="guessing no" ;;
+ # Guess yes otherwise.
+ *) gl_cv_func_btowc_eof="guessing yes" ;;
+ esac
+changequote([,])dnl
+ if test $LOCALE_FR != none; then
+ AC_TRY_RUN([
+#include <locale.h>
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+int main ()
+{
+ if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
+ {
+ if (btowc (EOF) != WEOF)
+ return 1;
+ }
+ return 0;
+}],
+ [gl_cv_func_btowc_eof=yes],
+ [gl_cv_func_btowc_eof=no],
+ [])
+ fi
+ ])
+ case "$gl_cv_func_btowc_eof" in
+ *yes) ;;
+ *) REPLACE_BTOWC=1 ;;
+ esac
+ fi
+ if test $HAVE_BTOWC = 0 || test $REPLACE_BTOWC = 1; then
gl_REPLACE_WCHAR_H
AC_LIBOBJ([btowc])
gl_PREREQ_BTOWC