1# mbswidth.m4 serial 13
2dnl Copyright (C) 2000-2002, 2004, 2006 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl autoconf tests required for use of mbswidth.c
8dnl From Bruno Haible.
9
10AC_DEFUN([gl_MBSWIDTH],
11[
12  AC_CHECK_HEADERS_ONCE([wchar.h wctype.h])
13  AC_CHECK_FUNCS_ONCE([isascii mbsinit])
14  AC_CHECK_FUNCS([iswcntrl])
15  gl_FUNC_MBRTOWC
16
17  dnl UnixWare 7.1.1 <wchar.h> has a declaration of a function mbswidth()
18  dnl that clashes with ours.
19  AC_CACHE_CHECK([whether mbswidth is declared in <wchar.h>],
20    ac_cv_have_decl_mbswidth,
21    [AC_TRY_COMPILE([
22#if HAVE_WCHAR_H
23# include <wchar.h>
24#endif
25], [
26  char *p = (char *) mbswidth;
27  return !p;
28], ac_cv_have_decl_mbswidth=yes, ac_cv_have_decl_mbswidth=no)])
29  if test $ac_cv_have_decl_mbswidth = yes; then
30    ac_val=1
31  else
32    ac_val=0
33  fi
34  AC_DEFINE_UNQUOTED(HAVE_DECL_MBSWIDTH_IN_WCHAR_H, $ac_val,
35    [Define to 1 if you have a declaration of mbswidth() in <wchar.h>, and to 0 otherwise.])
36
37  AC_TYPE_MBSTATE_T
38])
39