blob: e5d0457235eaec280ba450094cae0cb27fa3ed06 [file] [log] [blame]
Ying Wang05436632013-04-05 16:01:00 -07001# mbswidth.m4 serial 18
2dnl Copyright (C) 2000-2002, 2004, 2006-2012 Free Software Foundation, Inc.
The Android Open Source Projectcea198a2009-03-03 19:29:17 -08003dnl 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[
Ying Wang05436632013-04-05 16:01:00 -070012 AC_CHECK_HEADERS_ONCE([wchar.h])
13 AC_CHECK_FUNCS_ONCE([isascii mbsinit])
The Android Open Source Projectcea198a2009-03-03 19:29:17 -080014
15 dnl UnixWare 7.1.1 <wchar.h> has a declaration of a function mbswidth()
16 dnl that clashes with ours.
17 AC_CACHE_CHECK([whether mbswidth is declared in <wchar.h>],
Ying Wang05436632013-04-05 16:01:00 -070018 [ac_cv_have_decl_mbswidth],
19 [AC_COMPILE_IFELSE(
20 [AC_LANG_PROGRAM(
21 [[
22/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
23 <wchar.h>.
24 BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included
25 before <wchar.h>. */
26#include <stddef.h>
27#include <stdio.h>
28#include <time.h>
29#include <wchar.h>
30 ]],
31 [[
The Android Open Source Projectcea198a2009-03-03 19:29:17 -080032 char *p = (char *) mbswidth;
Ying Wang05436632013-04-05 16:01:00 -070033 return !p;
34 ]])],
35 [ac_cv_have_decl_mbswidth=yes],
36 [ac_cv_have_decl_mbswidth=no])])
The Android Open Source Projectcea198a2009-03-03 19:29:17 -080037 if test $ac_cv_have_decl_mbswidth = yes; then
38 ac_val=1
39 else
40 ac_val=0
41 fi
Ying Wang05436632013-04-05 16:01:00 -070042 AC_DEFINE_UNQUOTED([HAVE_DECL_MBSWIDTH_IN_WCHAR_H], [$ac_val],
The Android Open Source Projectcea198a2009-03-03 19:29:17 -080043 [Define to 1 if you have a declaration of mbswidth() in <wchar.h>, and to 0 otherwise.])
44
45 AC_TYPE_MBSTATE_T
46])