ffa6ece3bf17d0a7b23c56a298b476bba730c722
[gnulib.git] / m4 / mbswidth.m4
1 # mbswidth.m4 serial 11
2 dnl Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc.
3 dnl This file is free software, distributed under the terms of the GNU
4 dnl General Public License.  As a special exception to the GNU General
5 dnl Public License, this file may be distributed as part of a program
6 dnl that contains a configuration script generated by Autoconf, under
7 dnl the same distribution terms as the rest of that program.
8
9 dnl autoconf tests required for use of mbswidth.c
10 dnl From Bruno Haible.
11
12 AC_DEFUN([gl_MBSWIDTH],
13 [
14   AC_CHECK_HEADERS_ONCE(wchar.h wctype.h)
15   AC_CHECK_FUNCS_ONCE(isascii iswprint mbsinit)
16   AC_CHECK_FUNCS(iswcntrl wcwidth)
17   gl_FUNC_MBRTOWC
18
19   AC_CACHE_CHECK([whether wcwidth is declared], ac_cv_have_decl_wcwidth,
20     [AC_TRY_COMPILE([
21 /* AIX 3.2.5 declares wcwidth in <string.h>. */
22 #if HAVE_STRING_H
23 # include <string.h>
24 #endif
25 #if HAVE_WCHAR_H
26 # include <wchar.h>
27 #endif
28 ], [
29 #ifndef wcwidth
30   char *p = (char *) wcwidth;
31 #endif
32 ], ac_cv_have_decl_wcwidth=yes, ac_cv_have_decl_wcwidth=no)])
33   if test $ac_cv_have_decl_wcwidth = yes; then
34     ac_val=1
35   else
36     ac_val=0
37   fi
38   AC_DEFINE_UNQUOTED(HAVE_DECL_WCWIDTH, $ac_val,
39     [Define to 1 if you have the declaration of wcwidth(), and to 0 otherwise.])
40
41   dnl UnixWare 7.1.1 <wchar.h> has a declaration of a function mbswidth()
42   dnl that clashes with ours.
43   AC_CACHE_CHECK([whether mbswidth is declared in <wchar.h>],
44     ac_cv_have_decl_mbswidth,
45     [AC_TRY_COMPILE([
46 #if HAVE_WCHAR_H
47 # include <wchar.h>
48 #endif
49 ], [
50   char *p = (char *) mbswidth;
51 ], ac_cv_have_decl_mbswidth=yes, ac_cv_have_decl_mbswidth=no)])
52   if test $ac_cv_have_decl_mbswidth = yes; then
53     ac_val=1
54   else
55     ac_val=0
56   fi
57   AC_DEFINE_UNQUOTED(HAVE_DECL_MBSWIDTH_IN_WCHAR_H, $ac_val,
58     [Define to 1 if you have a declaration of mbswidth() in <wchar.h>, and to 0 otherwise.])
59
60   AC_TYPE_MBSTATE_T
61 ])