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