• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# wctob.m4 serial 4
2dnl Copyright (C) 2008-2009 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
7AC_DEFUN([gl_FUNC_WCTOB],
8[
9  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
10
11  AC_CHECK_FUNCS_ONCE([wctob])
12  if test $ac_cv_func_wctob = no; then
13    HAVE_DECL_WCTOB=0
14    gl_REPLACE_WCHAR_H
15    AC_LIBOBJ([wctob])
16    gl_PREREQ_WCTOB
17  else
18
19    dnl Solaris 9 has the wctob() function but it does not work.
20    AC_REQUIRE([AC_PROG_CC])
21    AC_REQUIRE([gt_LOCALE_FR])
22    AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
23    AC_CACHE_CHECK([whether wctob works],
24      [gl_cv_func_wctob_works],
25      [
26        dnl Initial guess, used when cross-compiling or when no suitable locale
27        dnl is present.
28changequote(,)dnl
29        case "$host_os" in
30            # Guess no on Solaris <= 9.
31          solaris2.[1-9] | solaris2.[1-9].*)
32            gl_cv_func_wctob_works="guessing no" ;;
33            # Guess yes otherwise.
34          *) gl_cv_func_wctob_works="guessing yes" ;;
35        esac
36changequote([,])dnl
37        if test $LOCALE_FR != none; then
38          AC_TRY_RUN([
39#include <locale.h>
40#include <string.h>
41#include <wchar.h>
42int main ()
43{
44  if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
45    {
46      wchar_t wc;
47
48      if (mbtowc (&wc, "\374", 1) == 1)
49        if (wctob (wc) != (unsigned char) '\374')
50          return 1;
51    }
52  return 0;
53}],
54            [gl_cv_func_wctob_works=yes],
55            [gl_cv_func_wctob_works=no],
56            [:])
57        fi
58      ])
59    case "$gl_cv_func_wctob_works" in
60      *yes) ;;
61      *) REPLACE_WCTOB=1 ;;
62    esac
63    if test $REPLACE_WCTOB = 1; then
64      gl_REPLACE_WCHAR_H
65      AC_LIBOBJ([wctob])
66      gl_PREREQ_WCTOB
67    else
68
69      dnl IRIX 6.5 has the wctob() function but does not declare it.
70      AC_CHECK_DECLS([wctob], [], [], [
71/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
72   <wchar.h>.
73   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be included
74   before <wchar.h>.  */
75#include <stddef.h>
76#include <stdio.h>
77#include <time.h>
78#include <wchar.h>
79])
80      if test $ac_cv_have_decl_wctob != yes; then
81        HAVE_DECL_WCTOB=0
82        gl_REPLACE_WCHAR_H
83      fi
84    fi
85  fi
86])
87
88# Prerequisites of lib/wctob.c.
89AC_DEFUN([gl_PREREQ_WCTOB], [
90  :
91])
92