annotate m4/wcsrtombs.m4 @ 10941:509592900669

New module 'wcsrtombs'.
author Bruno Haible <bruno@clisp.org>
date Sun, 21 Dec 2008 23:48:19 +0100
parents
children 47cd92ce639a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10941
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 # wcsrtombs.m4 serial 1
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
2 dnl Copyright (C) 2008 Free Software Foundation, Inc.
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 dnl This file is free software; the Free Software Foundation
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 dnl gives unlimited permission to copy and/or distribute it,
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 dnl with or without modifications, as long as this notice is preserved.
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 AC_DEFUN([gl_FUNC_WCSRTOMBS],
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8 [
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 AC_REQUIRE([AC_TYPE_MBSTATE_T])
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 AC_CHECK_FUNCS_ONCE([wcsrtombs])
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 if test $ac_cv_func_wcsrtombs = no; then
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 HAVE_WCSRTOMBS=0
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 else
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16 gl_WCSRTOMBS_TERMINATION
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 gl_WCSRTOMBS_NULL
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18 case "$gl_cv_func_wcsrtombs_termination" in
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 *yes) ;;
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20 *) AC_DEFINE([WCSRTOMBS_TERMINATION_BUG], [1],
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 [Define if the wcsrtombs function may set the source pointer to NULL without NUL-terminating the destination.])
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 REPLACE_WCSRTOMBS=1 ;;
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 esac
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 case "$gl_cv_func_wcsrtombs_null" in
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 *yes) ;;
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 *) AC_DEFINE([WCSRTOMBS_NULL_ARG_BUG], [1],
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 [Define if the wcsrtombs function has the NULL destination argument bug.])
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 REPLACE_WCSRTOMBS=1 ;;
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 esac
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 fi
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 if test $HAVE_WCSRTOMBS = 0 || test $REPLACE_WCSRTOMBS = 1; then
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 gl_REPLACE_WCHAR_H
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 AC_LIBOBJ([wcsrtombs])
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 gl_PREREQ_WCSRTOMBS
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 fi
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 ])
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 dnl Test whether the wcsrtombs implementation stores a non-NULL source pointer
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 dnl as long as it has not written the final NUL byte to the destination string.
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 dnl The OSF/1 5.1 implementation stores a NULL pointer already after storing
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 dnl the last non-NUL character, even if there is no more room for the
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 dnl terminating NUL character.
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 dnl Result is gl_cv_func_wcsrtombs_termination.
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 AC_DEFUN([gl_WCSRTOMBS_TERMINATION],
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 [
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
47 AC_REQUIRE([AC_PROG_CC])
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 AC_REQUIRE([gt_LOCALE_FR])
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50 AC_CACHE_CHECK([whether wcsrtombs updates the source pointer correctly],
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
51 [gl_cv_func_wcsrtombs_termination],
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 [
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 dnl Initial guess, used when cross-compiling or when no suitable locale
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 dnl is present.
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 changequote(,)dnl
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 case "$host_os" in
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 # Guess no on OSF/1.
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 osf*) gl_cv_func_wcsrtombs_termination="guessing no" ;;
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 # Guess yes otherwise.
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 *) gl_cv_func_wcsrtombs_termination="guessing yes" ;;
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 esac
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 changequote([,])dnl
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 if test $LOCALE_FR != none; then
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 AC_TRY_RUN([
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 #include <locale.h>
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 #include <stdlib.h>
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67 #include <wchar.h>
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 int main ()
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 {
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71 {
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72 const char original[] = "B\374\337er";
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 wchar_t input[10];
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
74
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
75 if (mbstowcs (input, original, 10) == 5)
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
76 {
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
77 const wchar_t *src = input;
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78 char output[5];
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 wcsrtombs (output, &src, 5, NULL);
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80 if (src != input + 5)
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81 return 1;
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82 }
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
83 }
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
84 return 0;
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
85 }],
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
86 [gl_cv_func_wcsrtombs_termination=yes],
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
87 [gl_cv_func_wcsrtombs_termination=no],
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
88 [])
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
89 fi
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
90 ])
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
91 ])
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
92
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
93 dnl Test whether the wcsrtombs implementation supports a NULL argument
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
94 dnl correctly. This is not the case on HP-UX 11.11 and OSF/1 5.1: These
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
95 dnl implementations updates the source pointer also if the destination argument
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
96 dnl is NULL.
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
97 dnl Result is gl_cv_func_wcsrtombs_null.
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
98
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
99 AC_DEFUN([gl_WCSRTOMBS_NULL],
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
100 [
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
101 AC_REQUIRE([AC_PROG_CC])
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
102 AC_REQUIRE([gt_LOCALE_FR])
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
103 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
104 AC_CACHE_CHECK([whether wcsrtombs supports a NULL argument correctly],
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
105 [gl_cv_func_wcsrtombs_null],
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
106 [
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
107 dnl Initial guess, used when cross-compiling or when no suitable locale
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
108 dnl is present.
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
109 changequote(,)dnl
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
110 case "$host_os" in
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
111 # Guess no on HP-UX and OSF/1.
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
112 hpux* | osf*) gl_cv_func_wcsrtombs_null="guessing no" ;;
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
113 # Guess yes otherwise.
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
114 *) gl_cv_func_wcsrtombs_null="guessing yes" ;;
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
115 esac
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
116 changequote([,])dnl
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
117 if test $LOCALE_FR != none; then
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
118 AC_TRY_RUN([
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
119 #include <locale.h>
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
120 #include <stdlib.h>
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
121 #include <wchar.h>
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
122 int main ()
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
123 {
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
124 if (setlocale (LC_ALL, "$LOCALE_FR") != NULL)
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
125 {
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
126 const char original[] = "B\374\337er";
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
127 wchar_t input[10];
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
128
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
129 if (mbstowcs (input, original, 10) == 5)
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
130 {
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
131 const wchar_t *src = input;
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
132 wcsrtombs (NULL, &src, 10, NULL);
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
133 if (src != input)
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
134 return 1;
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
135 }
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
136 }
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
137 return 0;
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
138 }],
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
139 [gl_cv_func_wcsrtombs_null=yes],
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
140 [gl_cv_func_wcsrtombs_null=no],
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
141 [])
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
142 fi
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
143 ])
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
144 ])
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
145
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
146 # Prerequisites of lib/wcsrtombs.c.
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
147 AC_DEFUN([gl_PREREQ_WCSRTOMBS], [
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
148 :
509592900669 New module 'wcsrtombs'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
149 ])