1 # vasnprintf.m4 serial 35
2 dnl Copyright (C) 2002-2004, 2006-2012 Free Software Foundation, Inc.
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.
7 AC_DEFUN([gl_FUNC_VASNPRINTF],
9 AC_CHECK_FUNCS_ONCE([vasnprintf])
10 if test $ac_cv_func_vasnprintf = no; then
15 AC_DEFUN([gl_REPLACE_VASNPRINTF],
17 AC_CHECK_FUNCS_ONCE([vasnprintf])
18 AC_LIBOBJ([vasnprintf])
19 AC_LIBOBJ([printf-args])
20 AC_LIBOBJ([printf-parse])
21 AC_LIBOBJ([asnprintf])
22 if test $ac_cv_func_vasnprintf = yes; then
23 AC_DEFINE([REPLACE_VASNPRINTF], [1],
24 [Define if vasnprintf exists but is overridden by gnulib.])
27 gl_PREREQ_PRINTF_PARSE
32 # Prerequisites of lib/printf-args.h, lib/printf-args.c.
33 AC_DEFUN([gl_PREREQ_PRINTF_ARGS],
35 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
36 AC_REQUIRE([gt_TYPE_WCHAR_T])
37 AC_REQUIRE([gt_TYPE_WINT_T])
40 # Prerequisites of lib/printf-parse.h, lib/printf-parse.c.
41 AC_DEFUN([gl_PREREQ_PRINTF_PARSE],
43 AC_REQUIRE([gl_FEATURES_H])
44 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
45 AC_REQUIRE([gt_TYPE_WCHAR_T])
46 AC_REQUIRE([gt_TYPE_WINT_T])
47 AC_REQUIRE([AC_TYPE_SIZE_T])
48 AC_CHECK_TYPE([ptrdiff_t], ,
49 [AC_DEFINE([ptrdiff_t], [long],
50 [Define as the type of the result of subtracting two pointers, if the system doesn't define it.])
52 AC_REQUIRE([gt_AC_TYPE_INTMAX_T])
55 # Prerequisites of lib/vasnprintf.c.
56 AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF],
58 AC_REQUIRE([AC_C_INLINE])
59 AC_REQUIRE([AC_FUNC_ALLOCA])
60 AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
61 AC_REQUIRE([gt_TYPE_WCHAR_T])
62 AC_REQUIRE([gt_TYPE_WINT_T])
63 AC_CHECK_FUNCS([snprintf strnlen wcslen wcsnlen mbrtowc wcrtomb])
64 dnl Use the _snprintf function only if it is declared (because on NetBSD it
65 dnl is defined as a weak alias of snprintf; we prefer to use the latter).
66 AC_CHECK_DECLS([_snprintf], , , [[#include <stdio.h>]])
67 dnl Knowing DBL_EXPBIT0_WORD and DBL_EXPBIT0_BIT enables an optimization
68 dnl in the code for NEED_PRINTF_LONG_DOUBLE || NEED_PRINTF_DOUBLE.
69 AC_REQUIRE([gl_DOUBLE_EXPONENT_LOCATION])
70 dnl We can avoid a lot of code by assuming that snprintf's return value
71 dnl conforms to ISO C99. So check that.
72 AC_REQUIRE([gl_SNPRINTF_RETVAL_C99])
73 case "$gl_cv_func_snprintf_retval_c99" in
75 AC_DEFINE([HAVE_SNPRINTF_RETVAL_C99], [1],
76 [Define if the return value of the snprintf function is the number of
77 of bytes (excluding the terminating NUL) that would have been produced
78 if the buffer had been large enough.])
83 # Extra prerequisites of lib/vasnprintf.c for supporting 'long double'
85 AC_DEFUN_ONCE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE],
87 AC_REQUIRE([gl_PRINTF_LONG_DOUBLE])
88 case "$gl_cv_func_printf_long_double" in
92 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
93 [Define if the vasnprintf implementation needs special code for
94 'long double' arguments.])
99 # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'double'
101 AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE],
103 AC_REQUIRE([gl_PRINTF_INFINITE])
104 case "$gl_cv_func_printf_infinite" in
108 AC_DEFINE([NEED_PRINTF_INFINITE_DOUBLE], [1],
109 [Define if the vasnprintf implementation needs special code for
110 infinite 'double' arguments.])
115 # Extra prerequisites of lib/vasnprintf.c for supporting infinite 'long double'
117 AC_DEFUN([gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE],
119 AC_REQUIRE([gl_PRINTF_INFINITE_LONG_DOUBLE])
120 dnl There is no need to set NEED_PRINTF_INFINITE_LONG_DOUBLE if
121 dnl NEED_PRINTF_LONG_DOUBLE is already set.
122 AC_REQUIRE([gl_PREREQ_VASNPRINTF_LONG_DOUBLE])
123 case "$gl_cv_func_printf_long_double" in
125 case "$gl_cv_func_printf_infinite_long_double" in
129 AC_DEFINE([NEED_PRINTF_INFINITE_LONG_DOUBLE], [1],
130 [Define if the vasnprintf implementation needs special code for
131 infinite 'long double' arguments.])
138 # Extra prerequisites of lib/vasnprintf.c for supporting the 'a' directive.
139 AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_A],
141 AC_REQUIRE([gl_PRINTF_DIRECTIVE_A])
142 case "$gl_cv_func_printf_directive_a" in
146 AC_DEFINE([NEED_PRINTF_DIRECTIVE_A], [1],
147 [Define if the vasnprintf implementation needs special code for
148 the 'a' and 'A' directives.])
149 AC_CHECK_FUNCS([nl_langinfo])
154 # Extra prerequisites of lib/vasnprintf.c for supporting the 'F' directive.
155 AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_F],
157 AC_REQUIRE([gl_PRINTF_DIRECTIVE_F])
158 case "$gl_cv_func_printf_directive_f" in
162 AC_DEFINE([NEED_PRINTF_DIRECTIVE_F], [1],
163 [Define if the vasnprintf implementation needs special code for
169 # Extra prerequisites of lib/vasnprintf.c for supporting the 'ls' directive.
170 AC_DEFUN([gl_PREREQ_VASNPRINTF_DIRECTIVE_LS],
172 AC_REQUIRE([gl_PRINTF_DIRECTIVE_LS])
173 case "$gl_cv_func_printf_directive_ls" in
177 AC_DEFINE([NEED_PRINTF_DIRECTIVE_LS], [1],
178 [Define if the vasnprintf implementation needs special code for
179 the 'ls' directive.])
184 # Extra prerequisites of lib/vasnprintf.c for supporting the ' flag.
185 AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_GROUPING],
187 AC_REQUIRE([gl_PRINTF_FLAG_GROUPING])
188 case "$gl_cv_func_printf_flag_grouping" in
192 AC_DEFINE([NEED_PRINTF_FLAG_GROUPING], [1],
193 [Define if the vasnprintf implementation needs special code for the
199 # Extra prerequisites of lib/vasnprintf.c for supporting the '-' flag.
200 AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST],
202 AC_REQUIRE([gl_PRINTF_FLAG_LEFTADJUST])
203 case "$gl_cv_func_printf_flag_leftadjust" in
207 AC_DEFINE([NEED_PRINTF_FLAG_LEFTADJUST], [1],
208 [Define if the vasnprintf implementation needs special code for the
214 # Extra prerequisites of lib/vasnprintf.c for supporting the 0 flag.
215 AC_DEFUN([gl_PREREQ_VASNPRINTF_FLAG_ZERO],
217 AC_REQUIRE([gl_PRINTF_FLAG_ZERO])
218 case "$gl_cv_func_printf_flag_zero" in
222 AC_DEFINE([NEED_PRINTF_FLAG_ZERO], [1],
223 [Define if the vasnprintf implementation needs special code for the
229 # Extra prerequisites of lib/vasnprintf.c for supporting large precisions.
230 AC_DEFUN([gl_PREREQ_VASNPRINTF_PRECISION],
232 AC_REQUIRE([gl_PRINTF_PRECISION])
233 case "$gl_cv_func_printf_precision" in
237 AC_DEFINE([NEED_PRINTF_UNBOUNDED_PRECISION], [1],
238 [Define if the vasnprintf implementation needs special code for
239 supporting large precisions without arbitrary bounds.])
240 AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
241 [Define if the vasnprintf implementation needs special code for
242 'double' arguments.])
243 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
244 [Define if the vasnprintf implementation needs special code for
245 'long double' arguments.])
250 # Extra prerequisites of lib/vasnprintf.c for surviving out-of-memory
252 AC_DEFUN([gl_PREREQ_VASNPRINTF_ENOMEM],
254 AC_REQUIRE([gl_PRINTF_ENOMEM])
255 case "$gl_cv_func_printf_enomem" in
259 AC_DEFINE([NEED_PRINTF_ENOMEM], [1],
260 [Define if the vasnprintf implementation needs special code for
261 surviving out-of-memory conditions.])
262 AC_DEFINE([NEED_PRINTF_DOUBLE], [1],
263 [Define if the vasnprintf implementation needs special code for
264 'double' arguments.])
265 AC_DEFINE([NEED_PRINTF_LONG_DOUBLE], [1],
266 [Define if the vasnprintf implementation needs special code for
267 'long double' arguments.])
272 # Prerequisites of lib/vasnprintf.c including all extras for POSIX compliance.
273 AC_DEFUN([gl_PREREQ_VASNPRINTF_WITH_EXTRAS],
275 AC_REQUIRE([gl_PREREQ_VASNPRINTF])
276 gl_PREREQ_VASNPRINTF_LONG_DOUBLE
277 gl_PREREQ_VASNPRINTF_INFINITE_DOUBLE
278 gl_PREREQ_VASNPRINTF_INFINITE_LONG_DOUBLE
279 gl_PREREQ_VASNPRINTF_DIRECTIVE_A
280 gl_PREREQ_VASNPRINTF_DIRECTIVE_F
281 gl_PREREQ_VASNPRINTF_DIRECTIVE_LS
282 gl_PREREQ_VASNPRINTF_FLAG_GROUPING
283 gl_PREREQ_VASNPRINTF_FLAG_LEFTADJUST
284 gl_PREREQ_VASNPRINTF_FLAG_ZERO
285 gl_PREREQ_VASNPRINTF_PRECISION
286 gl_PREREQ_VASNPRINTF_ENOMEM
289 # Prerequisites of lib/asnprintf.c.
290 AC_DEFUN([gl_PREREQ_ASNPRINTF],