a0274933b0bbb077dd6182ae8ef72cd734dc7805
[gnulib.git] / m4 / mbrtowc.m4
1 # mbrtowc.m4 serial 9
2 dnl Copyright (C) 2001-2002, 2004-2005, 2008 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 dnl From Paul Eggert
8
9 dnl This override of an autoconf macro can be removed when autoconf 2.60 or
10 dnl newer can be assumed everywhere.
11
12 m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.60]),[-1],[
13 AC_DEFUN([AC_FUNC_MBRTOWC],
14 [
15   dnl Same as AC_FUNC_MBRTOWC in autoconf-2.60.
16   AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
17     gl_cv_func_mbrtowc,
18     [AC_LINK_IFELSE(
19        [AC_LANG_PROGRAM(
20             [[#include <wchar.h>]],
21             [[wchar_t wc;
22               char const s[] = "";
23               size_t n = 1;
24               mbstate_t state;
25               return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
26        gl_cv_func_mbrtowc=yes,
27        gl_cv_func_mbrtowc=no)])
28   if test $gl_cv_func_mbrtowc = yes; then
29     AC_DEFINE([HAVE_MBRTOWC], 1,
30       [Define to 1 if mbrtowc and mbstate_t are properly declared.])
31   fi
32 ])
33 ])